I really like jQuery-File-Upload plugin, but it missed integration with Express.js. I ended up with adapting their node code as a middleware for Express.js. Example Express.js integration:
var express = require("express"), upload = require('jquery-file-upload-middleware'); var app = express(); app.configure(function () { ... app.use('/upload', upload({ uploadDir: __dirname + '/public/uploads', uploadUrl: '/uploads/' })); app.use(express.bodyParser()); ... });
This way upload middleware will be tied to /upload path, in the frontend you use /upload as url to upload files:<input id="fileupload" type="file" name="files[]" data-url="/upload" multiple> <script>$('#fileupload').fileupload({ dataType: 'json' })</script>Other options and their default values:
tmpDir: '/tmp', maxPostSize: 11000000000, // 11 GB minFileSize: 1, maxFileSize: 10000000000, // 10 GB acceptFileTypes: /.+/i, // Files not matched by this regular expression force a download dialog, // to prevent executing any scripts in the context of the service domain: safeFileTypes: /.(gif|jpe?g|png)$/i, imageTypes: /.(gif|jpe?g|png)$/i, imageVersions: { thumbnail: { width: 80, height: 80 } }, accessControl: { allowOrigin: '*', allowMethods: 'OPTIONS, HEAD, GET, POST, PUT, DELETE' }
IMPORTANT: jquery-file-upload-middleware should be registered before express.bodyParser(), or else upload progress events will not fire.
Get the code
very very thank you your excellent module! good man, God bless you!
ReplyDeleteHello,
ReplyDeleteIt is possible to use this middleware to uploading video files ?
Great module.
Thanks
Hi Aleksandr,
ReplyDeleteI'm testing your module and it's great but there's one thing that would be nice to have:
The ability to move files not just to a different Directory but also with the file name Renamed to whatever we choose, such as the file MD5.
Is there a way to do that without delving in the source code?
Thanks a lot,
JM
Hello,
ReplyDeleteI'm newbie, I can't get the module work. Please can some of you help me to get it work ( i.e small tutorial with code example ).
Thanks a lot
Thib
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteAlso, just found that when I ran it on Chrome, in my Mac, it returned
ReplyDeleteevents.js:85
throw er; // Unhandled 'error' event
^
Error: spawn convert ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)
Great content thanks for sharing this informative blog which provided me technical information keep posting.
ReplyDeletePython Online certification training
python Training institute in Chennai
Python training institute in Bangalore
The Blogs content is giving lots of ideas to find the solution.Thanks for explaining the content with Ease.For perceive more ideas visit below.
ReplyDeletepython training in chennai | python training in annanagar | python training in omr | python training in porur | python training in tambaram | python training in velachery
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteWow!!The codings are working.Thank you for sharing the blog. Java training in Chennai | Certification | Online Course Training | Java training in Bangalore | Certification | Online Course Training | Java training in Hyderabad | Certification | Online Course Training | Java training in Coimbatore | Certification | Online Course Training | Java training in Online | Certification | Online Course Training
ReplyDeleteMoney Gadget
ReplyDeleteMoney Gadget
Money Gadget
Money Gadget
Money Gadget
Money Gadget
Money Gadget
Money Gadget
Money Gadget
ReplyDeleteMoney Gadget
Money Gadget
Money Gadget
Money Gadget
Money Gadget
Money Gadget
Money Gadget