php - Laravel: how to access a file in the local disk? - File does not exist -


i'm trying edit excel file after uploading in laravel. file uploaded local disk, no 1 can access public.

filesystems.php

'local' => [         'driver' => 'local',         'root' => storage_path('app') 

routes.php

route::get('test',function() {      // create new phpexcel object     $objphpexcel = new phpexcel();     $objphpexcel = phpexcel_iofactory::load(storage::disk('local')->url('margin/analyser/0igkqqgmgxkhrv9isnbtrgyzfupfjz3cwjblgbdn.xlsx'));     $objphpexcel->setactivesheetindex(0);     echo $objphpexcel->getactivesheet()->gethighestrow(); })->middleware('admin'); 

i keep getting error:

could not open /storage/margin/analyser/0igkqqgmgxkhrv9isnbtrgyzfupfjz3cwjblgbdn.xlsx reading! file not exist. 

this works

     $objphpexcel = phpexcel_iofactory::load('..'.storage::disk('local')->url('app/margin/analyser/0igkqqgmgxkhrv9isnbtrgyzfupfjz3cwjblgbdn.xlsx')); 

but annoying. thought specifying 'root' => storage_path('app') in filesystems.php means storage::disk('local') in app directly

the url method used url file (ie: access browser). want use id get() method.

$contents = storage::get(''margin/analyser/0igkqqgmgxkhrv9isnbtrgyzfupfjz3cwjblgbdn.xlsx''); 

that being said, there still easier way manipulate uploaded files laravel.

// take uploaded file request // , store `/storage/somefolder` $path = $request->file('file')->store('somefolder'); 

you can use value returned $path access file.

edit

after discussion below, decided op that, if it's not the perfect solution, use $objphpexcel = phpexcel_iofactory::load('..'.storage::disk('local')->url($filelocation));.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -