-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
The file "" does not exist in MimeTypeGuesser.php:123 #23492
Comments
Can you detect witch type of files are causing this Exception? It's not a Laravel issue but a symfony/http-foundation related config issue. |
Thanks for getting back to me on this. Unfortunately I can't detect what the files are since the log does not show the file name and I don't log the upload posts. But from what I have seen all the other uploads so far has been MOV files (since it is video uploads). So I am assuming it might be a mov file recorded from iPhone. Since it doesn't happen to all files I am not sure. I also tried changing Thanks, |
Do you think if I use a try block as a dirty trick around this issue, is it ok? I mean something like this:
Its probably not addressing the core issue I guess. But is the above method worth trying or not recommended? |
I've seen this behavior when a file size larger than allowed in php settings. |
Mmm.. Now in a second look, I am not sure about your first validation: if (empty($file)) {
return response()->json(['error' => 'file not found.'], 400);
} Because in the symfony MimeTypeGuesser they ar validating So maybe you can replace your |
Hi @emilianotisato Thanks again. I actually added the Hi @devcircus I have 300MB as the max upload size and my frontend javascript shows an error if the file added is more than 300MB. However, now that you pointed it out, I think I might add a validation check before calling |
Yeah. Good point. It shouldn't get that far. |
Ok, here is an update on this and I have a feeling the issue is resolved. @devcircus was spot on with this. In the end, it does appear to be an issue with the max upload limit perhaps. I am not sure why it happened in the first place because my frontend javascript checks the max file size of 300MB before posting the data and similarly, my php was already set to the same 300MB limit. After your support, I was gonna approach this in 2 steps:
What I did: Since the last post, I added this to my controller:
Next, although my php setting already has 300MB max upload size, I increased it to 400MB so there is some breathing space between the limit I set in laravel controller and the original php settings. Therefore, I am now letting Laravel filter the max size to only 300MB although my php server is now set to 400MB. After the above 2 edits, I no longer see these error messages in the logs. So, I feel it might be safe to say the issue is resolved. I have been observing for couple of days and fingers crossed that it doesn't appear again. Thanks to @emilianotisato and @devcircus for your support. Your kindness helped me in resolving this issue I was stuck on for couple of weeks. Much obliged indeed. Cheers, |
I have this issue until 10 minutes ago when i read @devcircus and i realized that my file was too heavy. |
I had this same issue and it was the max upload limit on PHP. Look in your config file for a line that says Then restart your php server |
I thought I should chime in becuase I have just resolved this for myself. In my case I had everything already configured correctly as per the solutions above, which really got me scratching my head. It turns out I just didn't have It works now! I hope this can help someone else. |
Description:
I have Laravel Version 5.3 and sometimes when a user uploads a file, it fails with this message:
This error does not happen all the time and it only happens in some uploads. I notice these errors in my laravel logs.
The file is uploaded via Ajax (Angular) and the Laravel Controller that handles that POST, uses
getMimeType()
like this:What is interesting is, the code does not fail in
if (empty($file))
case if the file was really empty. But it only fails when it comes to$file->getMimeType()
line with the above error message.I have already searched the issues here and found couple of discussions like: #12350
I am still not sure what the solution here is. I don't want to upgrade Laravel to 5.6 yet and I dont want to edit the main application files inside
laravel/framework/src/
unless there is no other choice. Can someone help me understand what maybe the cause for this issue and how can I resolve this in Laravel 5.3?The text was updated successfully, but these errors were encountered: