In laravel i am making an application that uploads a file and the user can download that same file.
But each time i click to download i get this error.
The view code:
enter code here<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 that when i upload a file i remove its extension. Example: if i upload 'sample.pdf' it is saved as 'sample'.
I have no clue what is wrong as the path in the error is the correct path. And the file exists in that path. Plz help
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire