mardi 12 septembre 2017

How Do I return a file for download in Laravel

I need to be able to give the user a file for download, and so I created a route (unless I can do the link for a specific user's CV in blade). My files are stored in storage/app/cv/ directory. I created a route as such:

Route::get('test', function() {
    $destinationPath = config('app.CVDestinationPath') . "/static_file.pdf";
    $uploaded = Storage::get($destinationPath);
    return $uploaded;
}

However this route is giving me a weird output. I think it is the file but it is converting the file to html or something. Could anyone help me return the file (it could be pdf, doc, or docx, or plain text). My file is not stored in the public directory!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire