jquery-file-upload-middleware icon indicating copy to clipboard operation
jquery-file-upload-middleware copied to clipboard

[ERR_INVALID_CALLBACK]: Callback must be a function

Open moharm opened this issue 6 years ago • 1 comments

i use jquery-file-upload-middleware to upload my images to the server but it's crashed everytime !! this my config:

upload.configure({ uploadDir:'./store/test', uploadUrl: '/store/test',

}) app.use('/toto', upload.fileHandler());

in the front:

** the picture is uploaded but the app crashed and this is what i get :**

fs.js:136 throw new ERR_INVALID_CALLBACK(); ^

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function at makeCallback (fs.js:136:11) at Object.unlink (fs.js:938:14) at ReadStream. (D:\disktop\Stage 2\gestion d'absence\projet\node_modules\jquery-file-upload-middleware\lib\uploadhandler.js:149:48) at ReadStream.emit (events.js:194:15) at endReadableNT (_stream_readable.js:1125:12) at process._tickCallback (internal/process/next_tick.js:63:19)

moharm avatar Sep 03 '19 17:09 moharm

Hi there! I follow this path: \node_modules\jquery-file-upload-middleware\lib\uploadhandler.js:149:48 , after that I found solution here: https://stackoverflow.com/questions/53583183/i-have-got-typeerror-err-invalid-callback-callback-must-be-a-function/53591136

I changed this unlink to unlinkSync. It worked! if (!err) { **fs.unlinkSync(file.path);** generatePreviews(); }

hungvuongwork avatar Nov 05 '19 10:11 hungvuongwork