By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,799 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,799 IT Pros & Developers. It's quick & easy.

ssl file download problem

P: 190
HI All,

I have problem in files downloading over ssl. When am trying with IE Browser i got

"Internet Explorer cannot download 40 from
Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later."

Whem am tried with mozile firebox i can download small size files but could not download max size files... here my code

Expand|Select|Wrap|Line Numbers
  1. if(is_file($dir."/".$file))
  2.   {
  3.   header("Content-Disposition: attachment; filename=\"$file\";");
  4.   header("Content-Type: file/x-msdownload");
  5.   header("Content-Length: ".filesize($dir."/".$file));
  6.   //echo file_get_contents($dir."/".$file);
  7.   $handle = fopen($dir."/".$file, "rb");
  8.   while (!feof($handle)) echo fread($handle, 8192);
  9.   fclose($handle);
  10.   }
  11. else if(is_dir($dir."/".$file))
  12.     {
  13.     include_once("lib/zip.lib.php");
  15.     $newzip = new zipfile();
  16.     chdir($dir);
  17.     $name=$file;
  18.     add_dir($name,$newzip);
  20.     header("Content-Disposition: attachment; filename=".$name."");
  21.     header("Content-Type: file/x-msdownload");
  22.     $data=$newzip->file();
  23.     header("Content-Length: ".strlen($data));
  24.     echo $data;
  25.   }  
am using to add some methods like
header("Cache-Control: no-store, no-cache, must-revalidate");
but not succeed ... what is the problem....
Jun 9 '09 #1
Share this Question
Share on Google+
4 Replies

Expert 5K+
P: 5,058

You might have to enable SSL in IE.
You can find that in Tools->Internet Options->Advanced and then find the SSL options near the bottom of the list.

As to why Firefox would have problems with this, I do not know.
Is it giving you any errors? (Check the Tools->Error Console window)
Jun 9 '09 #2

P: 190
Off course i enabled ssl option in IE.

Tools->advanced->use ssl 1.0 & 2.0 & 3.0
Jun 10 '09 #3

P: 190
Hi All,

i got the answer.... I have modified my code as below and download is working fine....

Expand|Select|Wrap|Line Numbers
  1. header("Pragma: public");
  2.       header("Expires: 0");
  3.       header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4.       header("Cache-Control: private",false);
  5.       //header ( "Content-Type: $filedatatype" );
  6.       header("Content-Disposition: attachment; filename=\"".$file1."\";");
  7.       header("Content-Transfer-Encoding:* binary");
  8.       header("Content-Length: ".filesize($file));
But do not know why this code work under ssl... my guess is to determine the cache control is the solution....
Jun 10 '09 #4

Expert 5K+
P: 5,058
I'm glad you found a solution!
Thanks for sharing it.

I would put my bet on the Content-Transfer-Encoding:* binary header.
It tells the browsers how the data is encoded during the transfer.
Perhaps this is required when dealing with SSL transfers.

In any case, you can just comment the headers out, one by one. See which one causes the download to fail.
Jun 10 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.