I've used the following in a script I'm writing:
$file = $GLOBALS['gProdAttachUrl'].$row['fileName'];
$fileExt = getFileExt($file, 1);
$size = (int) filesize($file);
$fileName = $row['fileName'];
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Description: File Transfer");
header("Content-Type: application/force-download");
header('Content-Type: application/octet-stream; name="' . $fileName . '"');
header('Content-Type: application/octetstream; name="' . $fileName . '"');
header("Content-Disposition: attachment; filename=".$fileName);
header("Content-length: $size");
@readfile($file);
exit();
But when I go to download a file, it presents me with the file in question, but no content.
Basically, what is happening is a user clicks on a link, it calls get.product.attachment.php which in turn queries a mySQL database for the file name. Then I just do a little fancy footwork with the file name to get a file path, etc.
Whatever I'm doing, I'm doing it wrong. Any suggestions? I've tried getting the file through both IE and FireFox.
Thanks