Skip to content

EISDIR Error #423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JCarlos12 opened this issue Mar 30, 2017 · 6 comments
Closed

EISDIR Error #423

JCarlos12 opened this issue Mar 30, 2017 · 6 comments

Comments

@JCarlos12
Copy link

JCarlos12 commented Mar 30, 2017

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)
    });
@tunnckoCore
Copy link
Member

Use syntax highlighting next time.

As about the problem, It not make any sense to have some problems and thrown errors when there are not files selected, since it's not our job.

@lyyh3c
Copy link
Contributor

lyyh3c commented 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.

@JCarlos12
Copy link
Author

@lyyh3c Thaaaaaank you so much

It really helped.

How come it isnt part of the code in the first place

@tunnckoCore
Copy link
Member

tunnckoCore commented Mar 30, 2017

part.filename === undefined || part.filename === ''

It's just enough to be !part.filename - it handles any falsey values, including the empty strings.

@tunnckoCore
Copy link
Member

tunnckoCore commented Mar 30, 2017

close, since #424 by @lyyh3c, thanks!

@kornelski
Copy link
Contributor

This breaks tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants