Greetings all,

I am having great difficulties with an online app that I am developing.

To avoid issues with file permissions etc, I am saving files into a MySQL 
database (soon to be PostgreSQL), which works marvellously. Along with the 
contents of the file, I save the name, mime-type and size.

When it comes time to get the files back out, I have a script that gets hit 
using a URL something like "download.php?file=17" and looks like this;

------- start script --------
header("Expires: 0");
header("Cache-Control: no-cache");

// Get the file from the database into a standard result set
$getSQL = "SELECT * FROM Files WHERE id='$file'";
$fileResult = db_query($getSQL);
$theFile = db_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 
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"];

------ end script -------

Now this all works perfectly well on a normal (insecure) server, the file 
gets downloaded, the mime-type is correct, the filename presents itself for 
download and everything in sweet.

The problem is that the system I am developing is actually running on a 
secure server, and this does NOT work in that environment. I am testing on 
Internet Explorer 5 and it throws an error after you tell it you want to 
download the file, saying this;

---- error message ----
Internet Explorer cannot download ...load.php?file=17&download=yes from

Internet Explorer was not abl to open this Internet site. The requested 
site is either unavailable or cannot be found.
Please try again later.
---- end message ----

Not very helpful at all.

SO now I am at a standstill, I am completely stuck, and no one else I know 
has come up with anything that can solve the problem yet - any assistance 
would be fantastic - thanks all.


Beau Lebens - Web Master
Insurance My Way, Your Friendly Online Broker
(08) 9226 5888

PHP Database Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to