aguidrevitch / jquery-file-upload-middleware

jQuery-File-Upload Express.js middleware
294 stars 120 forks source link

Bug in documentation of Dynamic upload dir #7

Open ghost opened 11 years ago

ghost commented 11 years ago

Shoulnd't you add a next() at the end of the configuration?

        app.use('/upload', function (req, res, next) {
            // imageVersions are taken from upload.configure()
            upload.fileHandler({
                uploadDir: function () {
                    return __dirname + '/public/uploads/' + req.sessionID
                },
                uploadUrl: function () {
                    return '/uploads/' + req.sessionID
                }
            })(req, res, next);
            // This is the added Code
            next();
        });
aguidrevitch commented 11 years ago

Actually, upload.fileHandler is expected to be the only request handler, so no need for next()

ghost commented 11 years ago

Btw, I just tried using the exact same code, but it turned out not to work at all as expected: files were simply not uploaded :(

Does it have to do with where this piece of code is put in the configure function?

Cheers!

aguidrevitch commented 11 years ago

No errors at all ?

ghost commented 11 years ago

no not really !

aguidrevitch commented 11 years ago

Please let me know whether you're still in trouble

ghost commented 11 years ago

Well, I haven't done anything new since, but last time i used the exact code in the documentation, the files were not being uploaded.

aguidrevitch commented 11 years ago

are you on linux or windows ? have you configured tmpDir correctly ?

ghost commented 11 years ago

mac :P Well here's how I configured it:

upload.configure
  uploadDir: path.join(__dirname, "/tmp/uploads")
aguidrevitch commented 11 years ago

What is in uploadPath ? What happens when you try to upload ? Does the file appear in the __dirname + "/tmp/uploads" ? Have you checked with chrome dev console what server returns ?

ghost commented 11 years ago

Sorry for the delay mate, I won't be working on this till next week. i'll try to give a better debug log :)