alin19 Posted March 10, 2008 Share Posted March 10, 2008 how can i create a link for a download? i usualy used exactly the adres of the file, but i have a txt file and the instead of downloading it shows the file in the webpage Link to comment https://forums.phpfreaks.com/topic/95360-download-file/ Share on other sites More sharing options...
alin19 Posted March 10, 2008 Author Share Posted March 10, 2008 let me explain more detailed: i have a txt file on the server that contains a text : test test test test and i want the clients do download this text file, if the insert the adress of the text file: localhost/test.txt the browser writes : test test test test (exactly what is in the text file) Link to comment https://forums.phpfreaks.com/topic/95360-download-file/#findComment-488405 Share on other sites More sharing options...
bradkenyon Posted March 10, 2008 Share Posted March 10, 2008 $filename = 'test.txt'; header("Content-Length: " . filesize($filename)); header('Content-Type: application/text'); readfile($filename); Link to comment https://forums.phpfreaks.com/topic/95360-download-file/#findComment-488541 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.