-
-
Notifications
You must be signed in to change notification settings - Fork 682
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
Why I got TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null #668
Comments
If it works locally, maybe you have done something else on the server that causes this error. Also try to update your formidable version. |
Thank you for your answer, I thought my code has problem, if you seen that and you didn't find any mistake, I'll check server confing, but sometimes this happen when I add keep Extensions: true |
If I put formidable extension like below:
I will get that error message I added above already but if I use this method:
I did not get error message again, I checked formidable version I've been using latest version, I didn't find any special config or specific change on my server, moreover tmp folder permission is 777 |
Because this method does nothing in v2 anymore, so it should proceed with the defaults. Just for confirmation, are you installing the canary, or from git master branch? And, any reason why you explicitly define |
Thank for your answer, yes I did install formidable canary. Which form is not correct for v2 form.keepExtemsions or put options inside formidable? is there any way to define a specific port number for formidable? Because I know tmp folder has full read write execute (rwx) permission by default, Hence I'd expect my files transfer to this folder without any error but when I got this error tmp folder will be empty, based on error which path is mean of formidable, tmp path, path on client side, path defined by beginPath, I can't understand what path I should look or do research about that |
Passing to the options is the correct way. And there's a note for this. Using a constructor isn't recommended too.
We does nothing with ports. You pass a port to the server, so... |
Very well thank you so much, I think this error we are discussing about here, that would be relate to "file.path" , I can see some parts of my files will be upload but suddenly I'll get "path" error during upload process, formidable will crash because it got null, I don't know why during upload precedure program will get null, I'm pretty sure my files are heath and I did not upload any empty file, this will happen when I want upload file via laptop(client) to server, by the way if there is an option or any method can handle this sort of error such as null ( I don't know why suddenly formidable will get null among files! ) let me know, I put my code in try catch but it couldn't do any help. Thank in advance |
The thing is that we "analyze" the incoming files - like, getting the file extension, renaming, sanitizing and etc, and that's why. Unfortunately, it's possible that this may fail through this process... Does your file has extension? Can you just share the name of the file? What I'm seeing now is that probably Can you debug a bit for us? around 498 line // src/Formidable.js file
if (part && this.options.keepExtensions) {
const filename = typeof part === 'string' ? part : part.filename;
// console.log('keepExts', filename)
return `${name}${this._getExtension(filename)}`;
} and around 480 line _getExtension(str) {
// console.log('getExt str:', str)
const basename = path.basename(str);
// console.log('basename:', basename)
const firstDot = basename.indexOf('.');
const lastDot = basename.lastIndexOf('.');
const extname = path.extname(basename).replace(/(\.[a-z0-9]+).*/i, '$1');
if (firstDot === lastDot) {
return extname;
}
return basename.slice(firstDot, lastDot) + extname;
} |
Before everything I really appreciate for your answer, I think my issued fixed |
You're now getting Try using |
Bunch of thanks🙏, my problem solved, I'm using html tag |
Support plan
Enterprise):Community
Context
What are you trying to achieve or the steps to reproduce?
When I try to upload my files to the server I get this error. My code on localhost works without problem, but when I run the code on the server I get this error. I want my files after upload to be on my favorite path on the server.
What was the result you got?
What result did you expect ?
I'd expect my files to transfer to my favorite path on my server and the upload process to complete without any empty file or incomplete file.
The text was updated successfully, but these errors were encountered: