Reputation: 28344
I am using this to put the contents to a file
file_put_contents('abc.txt', $text);
I need to have a pop up for the user after this to save/download the file how would I do that
Upvotes: 3
Views: 6125
Reputation: 8320
This will give the user a download prompt:
<?php
header('Content-type: text/plain');
// What file will be named after downloading
header('Content-Disposition: attachment; filename="abc.txt"');
// File to download
readfile('abc.txt');
?>
Upvotes: 10
Reputation: 101251
You have to pass the right headers:
header("Content-disposition: Atachment");
Upvotes: 0
Reputation: 67745
Use the Content-Disposition header:
header('Content-Disposition: attachment; filename="abc.txt"');
readfile('abc.txt');
Be sure to send the appropriate Content-Type header as well.
Upvotes: 0