2012-09-19 6 views
0

jquery_form을 사용하여 서버를 표현하여 파일을 업로드하는 경우 진행률 표시 줄없이 진행됩니다. 진행률 표시 줄을 추가하는 데 도움이됩니다. 많은 사람들이이를 필요로합니다. 그래서 여기표현에 업로드 진행률 표시 줄을 추가하는 방법

코드를이다

클라이언트 측 :

$('#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, 
    }); 

    }); 

};

답변

관련 문제