Framework: [5.2.15] FileNotFoundException when uploading file through XHR

Created on 15 Feb 2016  路  17Comments  路  Source: laravel/framework

Before updating Laravel (5.2.12), my files (images) were uploading correctly through XHR.
After updating to 5.2.15, I get a FileNotFoundException in File.php line 37 with the following message:
The file "" does not exist

Some more details:

 1. in File.php line 37
 2. at File->__construct(false, true) in UploadedFile.php line 96
 3. at UploadedFile->__construct(false, 'logo-400x400.png', 'image/png', '17215', '0') in UploadedFile.php line 52
 4. at UploadedFile::createFromBase(object(UploadedFile)) in Request.php line 415
 5. at Request->Illuminate\Http\{closure}(object(UploadedFile))
 6. at array_map(object(Closure), array('image_file' => object(UploadedFile))) in Request.php line 416
 7. at Request->convertUploadedFiles(array('image_file' => object(UploadedFile))) in Request.php line 401
 8. at Request->allFiles() in Request.php line 304
 9. at Request->all() in Request.php line 1011
10. at Request->__get('image_src') in TeamController.php line 111
11. at TeamController->saveLogo(object(Request))

Most helpful comment

Same here:

`The file "" does not exist {"exception":"[object] (Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException(code: 0): The file \"\" does not exist at /(...)/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesser.php:123)
[stacktrace]

0 /(...)/vendor/symfony/http-foundation/File/File.php(79): Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser->guess('')

1 /(...)/app/Services/UploadService.php(59): Symfony\Component\HttpFoundation\File\File->getMimeType()

2 /(...)/app/Http/Controllers/UploadController.php(21): App\Services\UploadService->store(Object(Illuminate\Http\UploadedFile), 5, 23)

3 [internal function]: App\Http\Controllers\UploadController->store(Object(Illuminate\Http\Request), Object(App\Services\UploadService))

`

Using Laravel 5.5.20

All 17 comments

+1 I'm also having the same issue on the same very line. I guess the bug could have been introduced in either https://github.com/laravel/framework/commit/1f2124ef57bdd647979ab75a2863ce448118cca3 or https://github.com/laravel/framework/commit/834f56255946fa6d475fc5f4763b051f15550500. Anything else we can provide to make it easier to find the issue?

Hmm getRealPath must be returning false for the file.

Pushed a commit to fix.

:+1:

Thank you, Taylor! :+1:

I still have this error with my Laravel 5.2
FileNotFoundException in File.php line 37:
The file "/tmp/phpSkmSn7" does not exist

I follow the instruction at https://github.com/laravel/framework/issues/12350 and it works fine.
laravel/framework/src/Illuminate/Http/UploadedFile.php
at Line 50
remove instanceof static

I was also fall on this problem in 5.2.16 and in now i am using 5.2.29 and this is solved

I follow the instruction at #12350 and it works fine.
laravel/framework/src/Illuminate/Http/UploadedFile.php
at Line 50
remove instanceof static

Doing this fixed the same issue for me in V5.4.35.

I have this issue on 5.5.11. And removing instanceof static doesn't help.

I have the same issue on 5.5.19 and removing instanceof static fixes the problem for me, please fix @taylorotwell

Same here:

`The file "" does not exist {"exception":"[object] (Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException(code: 0): The file \"\" does not exist at /(...)/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesser.php:123)
[stacktrace]

0 /(...)/vendor/symfony/http-foundation/File/File.php(79): Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser->guess('')

1 /(...)/app/Services/UploadService.php(59): Symfony\Component\HttpFoundation\File\File->getMimeType()

2 /(...)/app/Http/Controllers/UploadController.php(21): App\Services\UploadService->store(Object(Illuminate\Http\UploadedFile), 5, 23)

3 [internal function]: App\Http\Controllers\UploadController->store(Object(Illuminate\Http\Request), Object(App\Services\UploadService))

`

Using Laravel 5.5.20

@cyrrill I'm having the same issue as well (using Laravel v5.5.26). Did you manage to find a solution to this one?

I have the same issue in laravel 5.3. Has anyone found a solution for this? The error I get in some cases when user tries to upload a video is:

Error: The file "" does not exist inFile/MimeType/MimeTypeGuesser.php:123

Same error today, does not look fixed

Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException: The file "" does not exist in file /srv/fb3/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesser.php on line 121
Stack trace:
  1. Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException->() /srv/fb3/vendor/symfony/http-foundation/File/MimeType/MimeTypeGuesser.php:121
  2. Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser->guess() /srv/fb3/vendor/symfony/http-foundation/File/File.php:79
  3. Symfony\Component\HttpFoundation\File\File->getMimeType() /srv/fb3/vendor/symfony/http-foundation/File/File.php:58
  4. Symfony\Component\HttpFoundation\File\File->guessExtension() /srv/fb3/vendor/laravel/framework/src/Illuminate/Http/FileHelpers.php:60
  5. Illuminate\Http\UploadedFile->hashName() /srv/fb3/vendor/laravel/framework/src/Illuminate/Http/UploadedFile.php:34
  6. Illuminate\Http\UploadedFile->store() /srv/fb3/app/Http/Controllers/Setup/StorageController.php:39
  7. FlowBox\Http\Controllers\Setup\StorageController->testUpload() /srv/fb3/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54
...

I got a similar error in Laravel 5.3 and I resolved it just recently: https://github.com/laravel/framework/issues/23492

Ah i found my fix - I set upload_max_filesize but then the system unexpectedly rebooted before I could restart httpd, and the change somehow got reverted to 2M.

So - this can happen also when you have too small upload_max_filesize and are uploading a big file. I guess we have to manually check the file object before trying to store it, somehow

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

YannPl picture YannPl  路  3Comments

CupOfTea696 picture CupOfTea696  路  3Comments

RomainSauvaire picture RomainSauvaire  路  3Comments

SachinAgarwal1337 picture SachinAgarwal1337  路  3Comments