Laravel-Excel: [BUG] 'File not found at path' when importing file on server while file_exists($path) returns true
Prerequisites
- Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
- Checked that your issue isn’t already filed.
- Checked if no PR was submitted that fixes this problem.
Versions
- PHP version: 7.1.16
- Laravel version: 5.7
- Package version: 3.1.1
Description
When I try following the documentation on importing a file stored on the server, I get an Illuminate\Contracts\Filesystem\FileNotFoundException
saying File not found at path: [path to file]
. However, a file_exists($path);
returns true.
Steps to Reproduce
- Install a fresh version of Laravel.
- Install Laravel Excel.
- Put your xlsx-file in the project folder, for example in the storage/app folder.
- Run
php artisan make:import UsersImport --model=User
. - Add the following code to a route, command or somewhere you can run it:
use Maatwebsite\Excel\Facades\Excel;
use App\Imports\UsersImport;
Excel::import(new UsersImport, storage_path('app/test.xlsx'));
- Run the code.
Expected behavior: According to the docs, the rows in the file should be imported to the users table.
Actual behavior:
Illuminate\Contracts\Filesystem\FileNotFoundException: File not found at path: [path]
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 21 (6 by maintainers)
This is not a bug. Put your excel file in “storage/app” folder. it use default disk config in config/filesystems.php
Check This Part of Documentation
Ah, my bad. I missed that part of the docs. Thank you!