【问题标题】:How could I use the uploaded image with no suffix of the server to the html page?如何使用上传的没有服务器后缀的图片到 html 页面?
【发布时间】:2017-03-01 20:57:44
【问题描述】:
$('#userInfoPhoto').html(function () {
    return '<img src="../uploads/' + thisUserObject.profileimage + '" alt = "userphoto" style="width:250px; height:250px"/>'
});

这是前端js 我怎么能像这样使用图像文件夹中的上传文件,而 thisUserObject.profileimage 是文件的名称(只是一个没有后缀的文件)

【问题讨论】:

  • 您是要去掉../uploads 部分还是图片的扩展名?

标签: javascript node.js express


【解决方案1】:

如果您只是想删除文件扩展名,您可以使用正则表达式来完成。

thisUserObject.profileimage.replace(/\.[^/.]+$/, "")

【讨论】:

    【解决方案2】:

    对不起各位,我只是上传目录搞错了,图片文件夹应该放在public文件夹中,html页面可以识别没有后缀的文件并将其添加到html页面中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-12
      • 1970-01-01
      • 1970-01-01
      • 2010-12-04
      • 1970-01-01
      相关资源
      最近更新 更多