Im trying to create a download file functionality, but it doesnt work, it gives me a error of: "The file "/storage/app/candidates/cvs/3/1493594353.pdf" does not exist", but im just looking at the file, and is there.
Am i missing something?
Note: im using laravel 5.4
File structure:
storage
- app
-- candidates
---cvs
----3
-----1493594353.pdf
- public
Route:
Route::post('candidate/cv/download-cv/','CurriculumVitaeController@downloadCV');
Controller:
public function downloadCV()
{
$candidate = Candidate::where('user_id',Auth::user()->id)->first();
$candidateCv = CandidateCv::where('candidate_id',$candidate->id)->first();
$path = Storage::url('app/candidates/cvs/'.$candidate->id.'/'.$candidateCv->cv);
$headers = ['Content-Type: application/pdf'];
$newName = 'cv-'.time().'.pdf';
return response()->download($path, $newName, $headers);
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2plazS2
via IFTTT
Aucun commentaire:
Enregistrer un commentaire