Page 1 of 1

Firefox screws up file name during download

Posted: Mon Feb 07, 2005 10:11 pm
by zixp
Hi, I have a page that sends a file as an attachment. It woks just fine in IE, but in Firefox, all but the first word on the filename is cut off. I am using basename(), and I have tried to put quotes in the header call unsucessfully. I am not very familiar with headers. Below is the code used, any suggestions on how to fix this would be greatly appreciated.

//Send file via header
if (isset($fileandpath) && file_exists($fileandpath)) {
header("Content-type: application/octet-stream");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($fileandpath));
header("Content-disposition: attachment; filename=".basename($fileandpath));
readfile("$fileandpath");
} else {
echo "No file selected, or file doesn't exist";
echo "file request is failed for: ".$file."<br>";

}

Posted: Mon Feb 07, 2005 11:04 pm
by feyd
urlencode() should take care of it nicely, or one of the over conversions..