rcj
rcj

Reputation: 661

displaying images in express js

Below, the img tag is showing GET /user/(%27./files/%27) 404

How do I make it look in the right place?

Jade file:

block content
    h1.
        #{user.name}
    ul
        li Email:   #{user.email}
        li Phone:   #{user.phone}
        li user ID: #{user._id}
        li <img src=('./files/' + user.name + '.png')/>

I tried adding the following to app.js

app.get('./files/*:path', function(req, res) {
    res.sendfile(path.resolve(req.params.path))
});

no change.

Upvotes: 0

Views: 63

Answers (1)

thalisk
thalisk

Reputation: 7743

Try this in your Jade template:

li
    img(src='./files/' + user.name + '.png')

Upvotes: 1

Related Questions