【发布时间】:2013-02-23 13:44:12
【问题描述】:
这是我的代码:
var thisImageName = thisRow["imagename"];
var thisImagePath = path.relative("./public", __dirname + "/public/uploads/" + thisImageName + ".jpg");
console.log(thisImagePath); // returns __dirname\public\uploads\
img.src = thisImagePath.split(path.sep).join("/");
为了得到合适的图像路径,我必须用路径分隔符分割,然后用合适的斜杠加入数组。有谁知道这样做更有效的方法?
【问题讨论】: