I had some file DOWNLOADS working for a while but then went to an SSL connection. I’m stuck! When I enter my ‘sendStream()’ function it executes and the headers are sent but no download dialog appears in the brower. This holds true for both IE and FF.
I’m at a loss and looking for a set of headers that will send a CSV file from a https location to the browser.
Can anyone help?
Appreciate any ideas….
tony
[CODE]
function sendStream($str, $type, $filenameHint=’upsImport’) {
$browser = whichBrowser();
if( !$filenameHint )
$filenameHint = “YourFile”;
switch ($type) {
case “exe”: (($browser==’IE’ || $browser==’OPERA’)? ($ctype=”application/octetstream”):($ctype=”application/octet-stream”));
break;
case “pdf”: $ctype=”application/pdf”;
break;
case “zip”: $ctype=”application/zip”;
break;
case “doc”: $ctype=”application/msword”;
break;
case “xls”: $ctype=”application/vnd.ms-excel”;
break;
case “ppt”: $ctype=”application/vnd.ms-powerpoint”;
break;
case “gif”: $ctype=”image/gif”;
break;
case “png”: $ctype=”image/png”;
break;
case “jpe”: case “jpeg”:
case “jpg”: $ctype=”image/jpg”;
break;
case “csv”: $ctype=”text/text”;
break;
default: $ctype=”application/force-download”;
}
header(‘HTTP/1.1 200 OK’);
header(‘Date: ‘ . date(“D M j G:i:s T Y”));
header(‘Expires: Mon, 26 Jul 1997 05:00:00 GMT’);
header(‘Last-Modified: ‘ . date(“D M j G:i:s T Y”));
header(“Cache-Control: no-store, must-revalidate”); // TB
header(“Content-Type: application/force-download”); // changed to force download
header(“Content-Length: ” .strlen($str) );
header(“Content-Transfer-Encoding: Binary”); // added
header(‘Content-Disposition: attachment; filename=”‘.$filenameHint.’.’.$type.'”‘);
/*
header(“Pragma: public”);
header(“Pragma: no-cache”);
// header(‘Expires: ‘.gmdate(‘D, d M Y H:i:s’).’ GMT’);
header(‘Expires: Mon, 26 Jul 1997 05:00:00 GMT’);
// header(“Last-Modified: ” .gmdate(“D, d M Y H:i:s”) .” GMT”); // TB
header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);
header(“Cache-Control: no-store, must-revalidate”); // TB
// header(“Cache-Control: private”,false);
header(“Content-Type: $ctype”);
header(“Content-Transfer-Encoding: binary”);
header(‘Content-Disposition: attachment; filename=”‘.$filenameHint.’.’.$type.'”‘);
header(‘Content-Length: ‘.strlen($str));
*/
set_time_limit(0);
echo $str;
}