我能够上传图像并将其存储在db中,也可以上传文件夹,但是无法在ejs html模板中动态显示图像。如果我提供直接的URL路径(例如src="/uploads/final.jpg"
),则可以显示图像,但是我在这里需要动态显示图像。
以下是一些屏幕截图:
<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9BUjdaNy5wbmcifQ==” alt =“在此处输入图像描述”>
<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9lbktkZS5wbmcifQ==” alt =“在此处输入图像描述”>
<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9HcEpwdi5wbmcifQ==” alt =“在此处输入图像描述”>
<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9zc3RrOS5wbmcifQ==” alt =“在此处输入图像描述”>
请查看您的架构,它是:
const postSchema = {
titel: String,
constent: String,
file: String
}
它说的是file
而不是path
,所以:
<%=post.file%>
应该工作