我使用Sails.js,它基于Node.js.对于上传我使用Dropzone。要显示我使用猫头鹰轮播的图片。
当我添加新图片并尝试显示时,我收到以下错误:
" NetworkError:404 Not Found - http://localhost:1337/superrare/b004421de079bb2531cc5cd6346d202d/dde8221dc9e0b750479cedd3924af191/dde8221dc9e0b750479cedd3924af191.png"
如果我在另一个标签中打开上面的链接,我可以看到图像,因为它存在于特定路径中。 如果我刷新页面,我可以看到猫头鹰旋转木马中的图片,上面显示的路径相同。
如果我为了测试目的而修改了Dropzone代码,那么在成功时将旧图片添加到轮播中,将显示图片 - > imagePath = '/superrare/b004421de079bb2531cc5cd6346d202d/d845a68e5a57acf2f879bcd50966cc11/d845a68e5a57acf2f879bcd50966cc11.png';
因此,只有当我尝试添加新的图片路径时,才会收到404错误...
如果我添加5秒的延迟,则错误与404相同。
这是我的代码
Dropzone.options.mydropzone = {
autoProcessQueue: false,
init: function () {
var imageName, imagePath, imageID;
var submitButton = document.querySelector("#submit-all");
myDropzone = this; // closure
this.on("success", function (file, responseJson) {
imageName = responseJson.createdAt;
imagePath = responseJson.path;
//imagePath = '/superrare/b004421de079bb2531cc5cd6346d202d/d845a68e5a57acf2f879bcd50966cc11/d845a68e5a57acf2f879bcd50966cc11.png';
imageID = responseJson.id;
var content = '<div class="item"><div id="visinput" class="container-img">'+
'<img file-id="' + imageID + '" src="' + imagePath + '">'+
'</div></div>';
// get owl element
var owl = $("#owlUpload");
// add item to owl carousel
setTimeout(function () {
owl.data('owlCarousel').addItem(content);
}, 5000);
document.getElementById("serverFile").value = fileProcess;
});
},
paramName: "file",
acceptedFiles: ".jpeg,.jpg,.png,.gif"
};