Hi guys, hopefully someone will catch this even tho this thread is a little older.
I have a problem that seems unique to anything I can find so far on the archives here and it goes a little something like this.
I have files saved directly into a database, after being parsed into monster-sized strings 🙂 along with the files, I am saving their original filename, the mime-type and the original file size. My problems occur when I attempt to get the files back out of the database, because IE starts having problems.
I am using a separate script which i have called download.php which is supposed to select the 'file' from the database, then basically dump a few headers to say what sort of file etc that it is, then stream the contents of the file from the database. it looks like this;
#######################
<?php
include("conf/preferences.php");
include("lib/generic.php");
header("Expires: 0");
header("Cache-Control: no-cache");
if (!$loggedUser) {
header("Location: $PCS_home?referrer=$PHP_SELF&msg=You must be logged in to view that page.<br>Please enter a valid username and password to continue.");
}
// Get the file from the database into a standard result set
$getSQL = "SELECT * FROM Files WHERE id='$file'";
$fileResult = mysql_query($getSQL);
$theFile = mysql_fetch_array($fileResult);
// If the file is intended as a download, then tell the browser to download it
// rather than display it.
if ($download == "yes")
header("Content-Disposition: attachment; filename=\"" . $theFile["name"] . "\"");
// Send a header telling the browser what type of file is coming and some details
header("Content-Type: " . $theFile["type"]);
header("Content-Description: PCS Database Saved File");
header("Content-Length: " . $theFile["size"] . "");
// Then pipe the file contents to the browser.
echo $theFile["contents"];
?>
#######################
This script works ok on a normal (insecure) server, except the filename still isn't passed correctly. Get this for wierd, it passes the extension of the filename (my theory is that it is effected by the mimetype) and the actual type properly, but still attempts to call the file "download" so I get things like "download.zip" and "download.doc"
My real problems occur when i transfer the script to the machine it is intended to run on which runs an SSL server (the insecure is for development). Then I get a problem because IE says it cannot find the page requested and I should try again later...
I have tried everything I can think of or find suggestions about - but to no avail, so now I am begging for help whereever I can get it! 🙂