I am pulling my hair out over this problem, and I am getting fairly desperate to find out the (probably simple) explanation
I have programmed a PHP system to upload files to a BLOB field in a MySQL database. No problems there, the file uploads fine, and I can see it there. The problem is when I try to use the header() function to spit it back out to a browser, the file downloads fine, with the correct filename, etc, but is completely un-openable. The contents of the file are perfect and intact, my computer just has no idea what type of file it is.
I originally created the system to be served off an IIS server to an IE browser, and it worked fine there. It is only once I ported it to Apache on a Linux box that I am getting this problem. I am convinced that I must be missing something in my headers that would resolve this issue, but I can't think what.
It is worth mentioning that when receiving the file, Mozilla tells me that it knows it is a file of (in this case) application/msword. But when it is saved and I go and look at it, it is of type unknown.
The code for the download is:
Code: Select all
<?php
header("Pragma: public");
header("Cache-control: private");
header("Content-Type: " .$this->getMimeType());
header("Content-Length: ".$this->getFileSize());
if(!$streaming) {
header("Content-Disposition: attachment;filename=" .$this->getFilename());
}
echo $this->getFileData();
?>Can anyone help me?
PS:
As an extra mention, the $streaming variable just makes sure that the browser is forced to download the content, not display or interpret it (as often happens with, say, images)
PPS:
If you want to check out the problem for yourself, it is on the downloads section of http://www.ferret.co.za