0
上午使用jquery_form上傳文件到express服務器,它工作正常。但沒有進度條,所以請幫助添加進度條。相信很多人也需要這個。如何在express上加載進度條
所以這裏是代碼
客戶端:
$('#uploadvideoform').ajaxSubmit({
error:function(xhr){
alert(xhr);
},
success:function(response){
var videopath = response.path;
var videoview = "<video width='320' height='240' controls='controls'>";
videoview += "<source src="+videopath+" type='video/mp4' />";
videoview += "Your browser does not support the video tag.";
videoview += "</video>";
$('#view_product_video_content').append(videoview);
},
})
return false;
服務器側:
exports.upload = function(req, res){
var serverPath = 'Temp\\' + req.files.productvideo.name;
// console.log('req.files.productvideo.path '+req.files.productvideo.path)
// console.log('F:\\unit2\\'+serverPath);
require('fs').rename(
req.files.productvideo.path,
'F:\\unit2\\'+serverPath,
function(error){
if(error){
console.log(error)
return;
}
res.send({
path:serverPath,
});
});
};