AshmanSNET Posted October 7, 2007 Share Posted October 7, 2007 G'day, I'm having a bit of difficulty with my download page. I'm trying to get a file to download from a path I set when the button is pressed, however the header() doesn't seem to like me entering the path to the file. How would I go about achieving this? I've looked for information on the net but can't seem to find anything helpful. Thanks Ashman www.settlers.net Quote Link to comment https://forums.phpfreaks.com/topic/72178-solved-download-file-using-form-button/ Share on other sites More sharing options...
haaglin Posted October 7, 2007 Share Posted October 7, 2007 This downloads the file specified in $file (with full path): $file = "path/file.whatever" header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.basename($file).'"'); header('Content-Transfer-Encoding: binary'); readfile($file); exit; Quote Link to comment https://forums.phpfreaks.com/topic/72178-solved-download-file-using-form-button/#findComment-363964 Share on other sites More sharing options...
AshmanSNET Posted October 7, 2007 Author Share Posted October 7, 2007 Thanks for the quick response, so simple too I'm kicking myself hah EDIT: Just tried it and it still does the same thing.... hmmm Quote Link to comment https://forums.phpfreaks.com/topic/72178-solved-download-file-using-form-button/#findComment-363966 Share on other sites More sharing options...
haaglin Posted October 7, 2007 Share Posted October 7, 2007 Please post your code.. Quote Link to comment https://forums.phpfreaks.com/topic/72178-solved-download-file-using-form-button/#findComment-363970 Share on other sites More sharing options...
AshmanSNET Posted October 7, 2007 Author Share Posted October 7, 2007 It works now. Thanks again...SOLVED! Quote Link to comment https://forums.phpfreaks.com/topic/72178-solved-download-file-using-form-button/#findComment-363973 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.