简体   繁体   中英

How to integrate project Expressjs with jQuery-File-Upload?

jQuery-File-Upload works well with Nodejs, but I found it difficult to integrate with Expressjs. Any suggestions? Thanks for your attention.

PD: https://github.com/blueimp/jQuery-File-Upload

there also exist a middleware for express: https://github.com/aguidrevitch/jquery-file-upload-middleware

express has formidable baked in via Connect's multi-part middleware eg you can simply POST files to an particular route and then use req.files to handle anything that has been uploaded.

A very simple option for handling file uploads is via the jQuery Form Plugin , and if you're using Jade as your template engine, you simply need a form that has a file input and the plugin should take care of the rest.

Try using https://github.com/felixge/node-formidable within your app, and make sure you don't have any async items (such as things that call a database) in your app.use() chain before formidable because they can cause you to loose data. Also be sure it's in an app.post(), not app.get() handler.

https://github.com/nfriedly/picsync-server/blob/master/app.js#L98 has a rough but working example of using express with formidable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM