question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I tried to submit a form with no file selected. I get an EISDIR error.

Is there anyway to catch no file selected error

here is my code snippet

    var form = new formidable.IncomingForm();
    var uploadPath = [];
    
    form.on('fileBegin', function (name, file) {
    		file.path = __dirname + '/upload/' + file.name;
	});
    
    form.on('file', function (name, file) {
		uploadPath.push(file.name);
	});
    
    form.parse(req, function (err, fields, files) {	
    	console.log(uploadPath)
    });

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
lyyh3ccommented, Mar 30, 2017

I met the same problem with you, and you can try like below: form.onPart = function(part) { if (‘’ != part.filename) { form.handlePart(part); } else { console.error(‘browser has not specified filename, please check it.’); } };

and I think we can also modify lib/incoming_form.js:185 in formidable (handlePart). formidable seems didn’t consider this situation. We can modify like below: if (part.filename === undefined) ===> if (part.filename === undefined || part.filename === ‘’)

I tried, the above two methods are OK.

0reactions
kornelskicommented, May 4, 2017

This breaks tests

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Node.js I get, "Error: EISDIR, read" - Stack Overflow
EISDIR error occurs when you try to open a file, but the path given is a directory. You can fix this by checking...
Read more >
Error: EISDIR: illegal operation on a directory, read · Issue #658
Error : EISDIR: illegal operation on a directory, read at Object.readSync (node:fs:625:3) at tryReadSync (node:fs:390:20) at Object.
Read more >
NPM stuck giving the same error EISDIR: Illegal operation on ...
Windows : NPM stuck giving the same error EISDIR : Illegal operation on a directory, read at error (native) [ Beautify Your Computer ......
Read more >
[error: eisdir: illegal operation on a directory, read] { errno ...
EISDIR stands for " Error, Is Directory ". This means that NPM is trying to do something to a file but it is...
Read more >
EISDIR: illegal operation on a directory when enable Remote ...
SDK Version: 41 Platforms(Android/iOS/web/all): Android When create a new App and enable Remote Debug, the CLI throws that exception: Error: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found