I have a setup that allows users to successfully upload MS word documents to a database (for the moment, the documents are actually being stored in the db, rather than just the URL). I also want to allow users to download selected documents. As of right now, I can download the selected files, but they get downloaded with the wrong filename. I have so far:
$data = @mysql_fetch_array($result);
if(!empty($data["specification"])) {
// Ouput the MIME header
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=" . $data["filename"]);
}
where "specification" is the column that contains the binary Word document, and "filename" is the actual filename, both stored in the db.
However, when I try to download the file, the download window, it says for the filename "download.php". And after being downloaded, the file is saved as "download.php". However, it's the right file b/c if I double click to open the document, it reads fine in Word.
How do I set the filename that is to be downloaded?