Jump to content

[SOLVED] Downloading a file through PHP works in firefox and safari, not IE


danno74

Recommended Posts

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  :shrug: . 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

 

 

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.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.