I think you need to specify the storage path. So something like:
storage_path($file->file_url)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm using https://github.com/Maatwebsite/Laravel-Excel to analyse Excel file.
I stored excel file in storage folder and store its info in database, the model is called FileUpload, it looks like this:
namespace App;
use Illuminate\Database\Eloquent\Model;
class FileUpload extends Model
{
protected $fillable = ['file_name', 'file_url', 'file_type'];
}
When I retrieve file data it looks like this
$file->file_url ==> "/storage/2/2017_09_25/10__Book2.xlsx"
when I use $file->file_url in view (like download link) it downloads properly, but when I use it in Maatwebsite Excel Facade, I use it like the following
$data = Excel::load( $file->file_url , function($reader) {})->get();
it throws exception like this
(1/1) PHPExcel_Reader_Exception
Could not open E:\Laravel Projects\portal\/storage/2/2017_09_25/44__Book2.xlsx for reading! File does not exist.
Which means it appends (E:\Laravel Projects\portal\) before my storage path, what should I do to read Excel file from internal storage??
If you have any other ideas I'll be much appreciated.
Please or to participate in this conversation.