Download The Text File Instead Of Opening In The Browser
i have one text file: When i click the Download it should download and save it in my local download path. I have tried. window.open('data.txt'); and header('Location:data.txt') B
Solution 1:
Try this:
$file = "data.txt";
$text = file_get_contents($file);
header("Content-Disposition: attachment; filename=\"$file\"");
echo$text;
Solution 2:
http headers may solve your problem, just referr
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
Solution 3:
Can you use this Jquery plugin http://jdownloadplugin.com/ to do the file download. It has many additional cool features for file downloading from web.
Solution 4:
if you are using apache and want to enforce downloading the txt files instead of opening them in browser. you can do using .htaccess
AddType application/octet-stream .txt
Solution 5:
I can tell you that you need to set header content-disposition as file attachment, but I do not know how to do it from JavaScript.
Post a Comment for "Download The Text File Instead Of Opening In The Browser"