Sails js Error in file Upload

Nakarmi

I have a form which have a input type file with name "uploadfile". No error occurs while a file is selected and form is submitted. But having this error while I don't select a file and submit the form.

`

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);

                  }
                });

` And in commad having this error

 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)
tsanzol

you should not use if statement for req.file(), you can check the length of array inside the function whenDone as in example below:

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});
      }
    });

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

bluebirdpromiseを使用したsails.jsreq.file.upload

分類Dev

Optional file uploads with Sails.js

分類Dev

jQuery-File-UploadなどのカスタムExpressミドルウェアをSails.jsに追加する

分類Dev

codeigniter not showing file upload error

分類Dev

react js handling file upload

分類Dev

Sails.js : post text input and a file in the same time

分類Dev

Starting Sails.js inside a Docker container causes a Grunt error

分類Dev

Starting Sails.js inside a Docker container causes a Grunt error

分類Dev

Sails.js 0.11 and passport: 'Missing Credentials' error

分類Dev

Unable to upload a file in Android and there's no details of an error

分類Dev

FTP File Upload - Filename Encoding Error

分類Dev

Error while using Primefaces 3.5 File Upload

分類Dev

Upload multiple file with vue js and axios

分類Dev

Angular JS File upload Content Disposition

分類Dev

AngularJS + sails.js

分類Dev

Error reading a file with Node js

分類Dev

angularjs angular-file-upload Unknown provider: $uploadProvider error

分類Dev

Fastlane upload to crashlytics fails with error fetching remote file

分類Dev

Error: write EPIPE when trying to upload file to FTP using gulp

分類Dev

WinSCP code 4 error when closing file after upload

分類Dev

how to resolve error in php during excel file upload

分類Dev

RabbitMQとSails.js

分類Dev

Sails JS Model Rest API

分類Dev

Node.js upload file into Buffer instead of /tmp

分類Dev

Laravel dusk: test file upload with Dropzone.js

分類Dev

Multiple File Upload with Dropzone.js and Laravel MediaLibrary Package

分類Dev

Kendo UI Angular Upload File to Backend as Node.JS

分類Dev

Kendo UI Angular Upload File to Backend as Node.JS

分類Dev

node.js file upload typeError Can not read property 'image'

Related 関連記事

  1. 1

    bluebirdpromiseを使用したsails.jsreq.file.upload

  2. 2

    Optional file uploads with Sails.js

  3. 3

    jQuery-File-UploadなどのカスタムExpressミドルウェアをSails.jsに追加する

  4. 4

    codeigniter not showing file upload error

  5. 5

    react js handling file upload

  6. 6

    Sails.js : post text input and a file in the same time

  7. 7

    Starting Sails.js inside a Docker container causes a Grunt error

  8. 8

    Starting Sails.js inside a Docker container causes a Grunt error

  9. 9

    Sails.js 0.11 and passport: 'Missing Credentials' error

  10. 10

    Unable to upload a file in Android and there's no details of an error

  11. 11

    FTP File Upload - Filename Encoding Error

  12. 12

    Error while using Primefaces 3.5 File Upload

  13. 13

    Upload multiple file with vue js and axios

  14. 14

    Angular JS File upload Content Disposition

  15. 15

    AngularJS + sails.js

  16. 16

    Error reading a file with Node js

  17. 17

    angularjs angular-file-upload Unknown provider: $uploadProvider error

  18. 18

    Fastlane upload to crashlytics fails with error fetching remote file

  19. 19

    Error: write EPIPE when trying to upload file to FTP using gulp

  20. 20

    WinSCP code 4 error when closing file after upload

  21. 21

    how to resolve error in php during excel file upload

  22. 22

    RabbitMQとSails.js

  23. 23

    Sails JS Model Rest API

  24. 24

    Node.js upload file into Buffer instead of /tmp

  25. 25

    Laravel dusk: test file upload with Dropzone.js

  26. 26

    Multiple File Upload with Dropzone.js and Laravel MediaLibrary Package

  27. 27

    Kendo UI Angular Upload File to Backend as Node.JS

  28. 28

    Kendo UI Angular Upload File to Backend as Node.JS

  29. 29

    node.js file upload typeError Can not read property 'image'

ホットタグ

アーカイブ