2015-01-29 4 views
2

"uploadfile"이라는 이름의 입력 파일이있는 양식이 있습니다. 파일을 선택하고 양식을 제출하는 동안 오류가 발생하지 않습니다. 하지만 파일을 선택하고 양식을 제출하지 않는 동안이 오류가 발생했습니다.돛 js 파일 올리기 중 오류가 발생했습니다.

events.js:72 
     throw er; // Unhandled 'error' event 
      ^
Error: ETIMEOUT: An Upstream (`NOOP_ques_uploadfile`) timed out waiting for file(s). No files were sent after waiting 10000ms. 
    at null.<anonymous> (C:\xampp\htdocs\kucbt_admin\node_modules\sails\node_modules\skipper\standalone\Upstream\Upstream.js:62:15) 
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15) 

답변

3

당신이 문 경우 사용하지 말아야합니다 req.file(), 아래 예와 같이 function whenDone 내부 배열의 길이를 확인할 수 있습니다

req.file('avatar').upload({ 
     saveAs: function(file, cb) { 
     cb(null, file.filename); 
     }, 
     dirname: uploadPath 
    }, function whenDone(err, uploadedFiles) { //onUploadComplete 
     if (uploadedFiles.length==0) { 
     //if no file selected. 
     sails.log.info('nothing selected'); 
     return res.view('showimage'); 
     } 
     if (err){ 
     return res.serverError(err); 
     } else{ 
     return res.view('showimage', {file:uploadedFiles}); 
     } 
    }); 
2

기본 ETIMEOUT 타이머가 확장 된 Skipper-의 0.5.5을 설치하십시오이 오류를 가진

if(req.file('uploadfile')._files.length>0){ 
       var ques_file = req.file('uploadfile'); 
       console.log('here'); 
       ques_file.upload({ 
        saveAs: function(file, cb) {      
          cb(null, file.filename); 
          }, 
        dirname: dirPath },function (err, files) { 
        if (err){       
        return res.serverError(err); 
        }else{      
        name =files[0].filename; 
        filename=name;      
        console.log("file : "+filename); 

        } 
       }); 

` 그리고 commad에서

`. 이전 버전에서도 ETIMEOUT에 의해 먹혀 들었던 다중 파티 양식 업로드 오류 (예 : 알 수없는 콘텐츠 유형)에서 많은 사용자의 ETIMEOUT 문제가 발생했습니다.

[email protected]를 설치하려면 직접 프로젝트와 configuring it as middlewarenpm install skipper --save을 수행하여 프로젝트에서 bodyparser로에서 가져올 수있다, 또는 당신은 업데이트와 함께 제공 항해의 v0.11.x를 설치할 수 있습니다 번역.

은 오늘로서, 항해의 v0.11는 NPM의 "베타"태그로 출시, 그래서 당신은 사용하여 프로젝트에 직접 설치할 수 있습니다

npm install [email protected] --save

+0

나는 선장을 설치하고 작동하지 않았다 시도했다. 다시 돛 @ 베타를 설치했지만 여전히 작동하지 않습니다. 같은 오류가 있습니다. – Nakarmi

관련 문제