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

 

 

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.