MSIE problem with binary file download over SSL
| From: | Rich Choy | Date: | Tue, 08 Apr 2003 00:46:45 +0000 |
| Subject: | MSIE problem with binary file download over SSL | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-142774@lists.php.net to get a copy of this message | ||
Hi,
I have a script that retrieves binary blob data from a database and sends it
to the client browser via SSL. It works like a charm for all browsers except
for MSIE. I can assure you that the problem has nothing to do with the way
I've set up my headers; after a bit of investigation I've figured out that
MSIE has a problem with my script when it sends data over SSL. I have tested
the script with MSIE over a regular port 80 connection and the download
script works just fine.
I am running Apache 1.3.6 + OpenSSL 0.9.6g + PHP 4.1.2. Does anyone know a
workaround to this problem? I have looked all over the web to no avail. Any
help is appreciated.
Thanks in advance,
Rich
Here's the download script:
[begin php]
<?
include("_srs/res_common_sdx_admin.inc");
include("_srs/res_auth_admin.inc");
$id = $_GET['id'];
if ($id) {
// if record id was specified
@include("res_db.inc");
// connect to database
$db_q['lit'] = "select * from sdx_literature where id = $id";
$db_r['lit'] = mysql_query($db_q['lit']);
if (mysql_num_rows($db_r['lit'])==1) {
// if record exists
$lit = mysql_fetch_array($db_r['lit']);
// fetch literature record
$file_description = $lit['description'];
$file_name = $lit['filename'];
$file_size = $lit['byte_size'];
$mime_type = $lit['mime_type'];
$binary_data = $lit['binary_data'];
if (preg_match('/MSIE 5.5/', $_ENV['HTTP_USER_AGENT']) ||
preg_match('/MSIE 6.0/', $_ENV['HTTP_USER_AGENT'])) {
header("Content-Disposition: filename=$file_name");
header("Content-Type: application/zip");
// headers for MSIE
} else {
header("Content-Disposition: attachment;
filename=$file_name");
header("Content-Type: $mime_type");
// headers for WC3-compliant clients
}
header("Content-Length:$file_size");
header("Content-Transfer-Encoding: binary");
header("Content-Description: $file_description");
// common headers
echo $binary_data;
// send binary data to client
} else {
// if record does not exist
$_SESSION['msg'] = "Invalid literature record ID.";
// error message
}
} else {
// if record id was not specified
$_SESSION['msg'] = "The script you are trying to access requires a
valid literature record ID.";
// error message
}
header("Location: error.php");
// redirect to error notification script
?>
[end php]