danno74 Posted August 7, 2009 Share Posted August 7, 2009 Greetings all! I have this code in my software download page so that when you click on a link to download a program, you cannot obtain the direct link: <?php session_start(); if (isset($_SESSION['fullname'])) { //Location of file, must be out of web root $file_location='/downloads/FileZilla_2_2_7c_setup.exe'; //open file $file=fopen($file_location,'r'); //get file size $file_size=filesize($file_location); //read the file $content=fread($file,$file_size); //close the file fclose($file); //supply the right file format header('Content-type: application/exe'); //force browser to prompt to download file //cool option of this header is that allows you to rename the file header('Content-Disposition: attachment; filename="FileZilla_2_2_7c_setup.exe"'); //finally echo content echo $content; } else header("Location: https://www"); ?> Works in FF and Safari, not IE . I get this error: IE cannot download title2.php from www. IE was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later. Any ideas? Thanks for your help! - Dan Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted August 7, 2009 Share Posted August 7, 2009 Are you accessing the download page over ssl? Quote Link to comment Share on other sites More sharing options...
alexdemers Posted August 7, 2009 Share Posted August 7, 2009 Use PHP: readfile - Manual instead. Make sure to include the headers: Pragma: no-cache Expires: 0 Quote Link to comment Share on other sites More sharing options...
alexdemers Posted August 7, 2009 Share Posted August 7, 2009 To add to my previous post: set headers and call readfile('yourfile.txt'); that's it. Quote Link to comment Share on other sites More sharing options...
danno74 Posted August 10, 2009 Author Share Posted August 10, 2009 Mark - it is on our secure shtml tree on the server. So the SSL cert and https does apply, but it's just the area of the test server I have access to, on production it will be on http. Thanks alex, I will work on that header info and see if that works. Quote Link to comment Share on other sites More sharing options...
danno74 Posted August 10, 2009 Author Share Posted August 10, 2009 I added the expire and pragma and it worked! I didn't know what you meant to do in your second post. Thank you! Quote Link to comment 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.