How do I make the browser ask what a user wants to name a downloaded file - with a suggestion

Posted 9 months ago by autefrum

I have created a CSV file and stored it in $randomFilePath = public_path().'/temp/'.substr(md5(rand()), 0, 7).".csv"; and want to send it to the user's browser as a download.

This is working - I am using: return response()->download($filePath,$desiredFileName ,[ 'Content-Type' => 'text/csv', 'Content-Length' => filesize($filePath), 'Content-Disposition' => 'attachment; filename="'.$desiredFileName.'"', ])->deleteFileAfterSend(true);

However, I want to prompt the user to confirm what they want to name the file.

it currently just saves the file as $desiredFileName, but i want a box to pop up asking where they want to save it.

Is this a browser config issue? Or is there a reliable cross-broswer way to do this?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.