PDA

View Full Version : php help please..


maximillion
09-27-2011, 06:15 PM
k, i have this site and on it i have links to text files, but normally when you click the link - the link opens the file in the browser... what i want is instead of viewing it, i want to make the text files downloads...

the reason for this is i made a word search puzzle maker, but i am also offering free puzzles you can download. the puzzles are txt files - so viewing them is not what i want, but instead for them to download them and put them in the apps puzzle folder so they can play them with the app.

Inf3rnal
09-28-2011, 08:32 AM
There isn't a sure way to make links that will download. Those are processed on the browser depending on the users settings.

Try using buttons:
<form><input type="button" value="Download Now" onClick="window.location.href='Your.txt'"></form>

I haven't tested it but it's worth a shot.

Csar
11-11-2011, 01:30 PM
Maybe this PHP Code helps:
<?
header('Content-Disposition: attachment; filename="downloaded.pdf"');
?>

It'll force the browser to display the file download dialog.

Empress_Swanbottom
04-01-2013, 02:03 AM
Perhaps this'll help?
http://php.net/manual/en/function.readfile.php

Hall of Famer
04-01-2013, 04:01 AM
Well the OP's last activity was in Oct 2011...