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.
php artisan make:import UsersImport --model=User.use Maatwebsite\Excel\Facades\Excel;
use App\Imports\UsersImport;
Excel::import(new UsersImport, storage_path('app/test.xlsx'));
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]
@mattias-persson
Try this one instead:
Excel::import(new UsersImport, 'test.xlsx');
See Importing from default disk for more information how to deal with the files you'd like to import.
Ah, my bad. I missed that part of the docs. Thank you!
i have same trouble, :(
controller:
namespace App\Http\Controllers\Admin;
use App\Model\Mahasiswa;
use App\Model\UsersImport;
use Maatwebsite\Excel\Facades\Excel;
use App\Http\Controllers\Controller;
use App\Http\Requests;
class UserimController extends Controller
{
public function import()
{
Excel::import(new UsersImport, 'Mahasiswa.xlsx');
return back()->with('success', "Import data succesfull");
}
}
and My class or model:
namespace App\Model;
use App\Mahasiswa;
use Maatwebsite\Excel\ConcernsToModel;
class UsersImport implements ToModel
{
/**
public function model(array $row)
{
return new Mahasiswa([
'npm' => $row[0],
'nama_mahasiswa' => $row[1],
'jenis_kelamin' => $row[2],
'tanggal_lahir' => $row[3],
]);
}
}
and the error:
League \ Flysystem \ FileNotFoundException
File not found at path: Mahasiswa.xlsx
and:
public function assertPresent($path)
{
if ($this->config->get('disable_asserts', false) === false && ! $this->has($path)) {
throw new FileNotFoundException($path);
}
}
whats wrong on my work :(
hmmm
controller
`
namespace App\Http\Controllers\Admin;
use App\Model\Mahasiswa;
use App\Model\UsersImport;
use Maatwebsite\Excel\Facades\Excel;
use App\Http\Controllers\Controller;
use App\Http\Requests;
class UserimController extends Controller
{
public function import()
{
Excel::import(new UsersImport, 'Mahasiswa.xlsx');
return back()->with('success', "Import data succesfull");
}
}
`
class or model:
`
namespace App\Model;
use App\Mahasiswa;
use Maatwebsite\Excel\ConcernsToModel;
class UsersImport implements ToModel
{
/**
public function model(array $row)
{
return new Mahasiswa([
'npm' => $row[0],
'nama_mahasiswa' => $row[1],
'jenis_kelamin' => $row[2],
'tanggal_lahir' => $row[3],
]);
}
}
`
and this error
League \ Flysystem \ FileNotFoundException
File not found at path: Mahasiswa.xlsx
and my database is

@GlennM please help me :(

@GlennM please help me :(
@Emha2403 Please check the location of your file. It looks like the file you're trying to import is not at the right location.
You should be able to find the correct directory by checking which disk you're using and find the corresponding root path for that driver.
hi, I meet the same question, and i am sure my file has been uploaded at the right url i using
hi, I meet the same question, and i am sure my file has been uploaded at the right url i using
@williams-young Could you please open a new issue (according to the issue template) mentioning all relevant information? Thanks!
This is not a bug. Put your excel file in "storage/app" folder. it use default disk config in config/filesystems.php
xxxxxxxxxxxxxxxxxxx\storage\app
el archivo excel debe ir en la siguiente ruta.
xxxxxxxxxxxxxxxxxxx\storage\app
el archivo excel debe ir en la siguiente ruta.
Please post any support related questions or comments in English please if you would like us to provide support.
I understand that this behavior is documented, but again it just seems bizarre and unintuitive. If you pass it an absolute filePath that comes back as true from file_exists()....it should load. There seems to be many unnecessary "gotchas" with this package, even when trying to do very basic import operations.
I have a 4 column XLSX with 100 rows that I want to import into a collection. I've had to visit the forums for filePath issues, dates coming back as integers, and trying to figure out what the point of these generated XYZImport classes are when I am trying to import a small xlsx to a collection.
If you pass it an absolute filePath that comes back as true from file_exists()....it should load
I agree on this. Seems like it causes confusion for a lot of users.
I agree on this being confusing.
Can't the documentation mention the default storage/app path? I know this is configurable and all but im pretty sure this would give users with less of a laravel knowledge an easier time.
I agree on this being confusing.
Can't the documentation mention the default
storage/apppath? I know this is configurable and all but im pretty sure this would give users with less of a laravel knowledge an easier time.
If you think the documentation lacks some information, you're always welcome to submit a pull request to the docs. You can do so by using the Help us improve this page!link located at the bottom of each page.
count me in with the confused.. was trying to pass an absolute path using base_path() since my files are stored outside the storage folder and in a special "modules" folder.. couldn't get it to work, finally had to move my files into the storage path. If the path received starts with a front slash it should just assume that it's an absolute path IMO
Yeah, actually it seems that even after adding files to storage it can't find it. Judging by the error response it's trying a relative path in the end :man_facepalming: .
It has been documented for a few months that using absolute paths is possible: https://docs.laravel-excel.com/3.1/imports/basics.html#importing-full-path
I'll lock this ticket to keep the support process streamlined. If new bugs or questions arise, please create a new issue explaining your specific case.
Most helpful comment
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