laravel 5 - FileNotFoundException in File.php line 41 -


in laravel making application uploads file , user can download same file.

but each time click download error. enter image description here

the view code:

<h5><a href="/download/{{$filesharing->filename}}/{{$filesharing->filetype}}">download</a></h5> 

the route code:

route::get('/download/{filename}/{filetype}', 'filesharingscontroller@download'); 

the controller code:

public function download($filename, $filetype){     $downloadpath = public_path(). '/assests/' . $filename ;     $headers =  array(         'content-type: application/octat-stream',         'content-type: application/pdf'     );      return response::download($downloadpath, $filename . '.' . $filetype, $headers); } 

please not when upload file remove extension. example: if upload 'sample.pdf' saved 'sample'.

i have no clue wrong path in error correct path. , file exists in path. plz help

the folder structure: enter image description here

and code used upload file is:

// save uploaded file     if ($this->request->hasfile('file') && $this->request->file('file')->isvalid()) {         $destinationpath = public_path() . '/assests/';         $filename = $filesharing->filename . '.' . $this->request->file('file')->guessclientextension();         $this->request->file('file')->move($destinationpath, $filename);     } 

your $downloadpath missing file extension. second parameter of response::download file name shown user.

your variable should this:

$downloadpath = public_path() . '/assets' . $filename . '.' . $filetype; 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -