andreigirnet96's avatar

I am trying to update my cv on my portfolio website. After updating the route still downloads the old one

I am trying to update my cv on my portfolio website. After updating the route still downloads the old one. I would like to note that when I am introducing the url link manually on the search bar of the browser everything works fine. I hope I have explaied clea the problem. Here is the code

Route::get('/download/cv', function(){
    $file = storage_path()."/cv/resumeAndrei.pdf";
    return response()->download($file,'resumeAndrei.pdf');
})->name('andrei.cv');
<form method="get" action="{{route('andrei.cv')}}">
            <button type="submit">
                <div id="button-download"  style="margin-top: 50px">
                    <div id="overflow"></div>
                    <div style="color: white; margin-left: 30px; ">DOWNLOAD CV</div>
                    <div id="arrow"><img src="{{asset('assets/icons/arrow.png')}}" alt=""></div>
                </div>
            </button>
        </form>
0 likes
5 replies
jaseofspades88's avatar

You don't need to submit this via a form, simply use an anchor tag and put the link in the href="" attribute.. If you dump out the $file is it giving you the correct file path?

1 like
Sinnbeck's avatar

@andy12441 you can use an a tag with the download keyword

<a href="{{route('andrei.cv')}}" download>download dc</a>
1 like
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Maybe browser cache

return response()->download($file,'resumeAndrei.pdf');
})->name('andrei.cv.pdf?v=2'); 
AddWebContribution's avatar

@andreigirnet96 You could try adding a timestamp to the filename when returning the download response. Sometimes browsers cache downloads pretty aggressively if the filename stays the same. For example:

$file = storage_path()."/app/cv/resumeAndrei.pdf";
$timestamp = now()->timestamp;

return response()->download($file, "resumeAndrei_{$timestamp}.pdf");

Please or to participate in this conversation.