I'm trying to upload an image and show it in express. I configured my app to upload in 'public/images'
app.use(express.bodyParser({ keepExtensions: true, uploadDir: './public/images' }));
The upload goes great but I can't find how to show uploaded images in my jade template. The image path I get from the req.files object is something like 'public/images/imagename.jpg' but the only way I can see images is in a url like this:
http://localhost:3000/images/imagename.jpg
Is there a way to maybe remove the 'public' parameter from req.files, or are there other solutions?? Thanks everyone!
EDIT:
Ok, thanks for that. But my question was about showing images in the jade template. I added this line:
app.use('/public/images/', express.static(__dirname + '/public/images/'));
and now I can reach files in that directory. But I'm not able to show them in my jade template. When I try this (with foto_path === req.files.image.path):
img(src= #{material.foto_path})
I get this url:
http://localhost:3000/undefinedpublic/images/b1ce29f40ac7692ac62637e42f0f9128.jpgundefined
What are the 'undefined' for?
Thanks!!