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")
But both are open the text file browser it self. I what download the txt file.
Any one please help me..
Thanks
Manikandan.
href = data . This will cause the browser to download the file.
There are tens of reasons which can cause this issue of downloading files instead of opening in browser. But mainly you get this issue due to poor hosting provider, any deflect in cache plugin you're using on your website, or you messed up with the . htaccess file.
Click on "Settings" and you'll see a new page pop up in your Chrome browser window. Scroll down to Advanced Settings, click Downloads, and clear your Auto Open options. Next time you download an item, it will be saved instead of opened automatically.
Try this:
$file = "data.txt";
$text = file_get_contents($file);
header("Content-Disposition: attachment; filename=\"$file\"");
echo $text;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With