Firefox Truncating Download Filenames
Posted: Sun Nov 27, 2005 8:16 am
As recommended to me in a post a while back
viewtopic.php?t=37539&highlight=
I am trying to download photo outside of the www folder using the following code. The script queries the database using the ID of the photo to pull the full file address to the file and the file name only (since it is already in the database and base() was truncating my file name). First, I use the script to insert the selected photo as a SRC element with a link to download a larger file. The SRC element works great in IE and Firefox, but the link for the download only works in IE. In Firefox the name gets truncated where there is a space in the file name. Firefox ask me to save or open the file, but the file name is truncated and when it saves the files it has nothing in it. Though files names that do not have spaces work fine.
Is this a bug in Firefox or is there something wrong in my script that IE is compensating for? Do have to get rid of all spaces in my file names (I fear this is what I may have to do)? Any suggestions? Thank you.
viewtopic.php?t=37539&highlight=
I am trying to download photo outside of the www folder using the following code. The script queries the database using the ID of the photo to pull the full file address to the file and the file name only (since it is already in the database and base() was truncating my file name). First, I use the script to insert the selected photo as a SRC element with a link to download a larger file. The SRC element works great in IE and Firefox, but the link for the download only works in IE. In Firefox the name gets truncated where there is a space in the file name. Firefox ask me to save or open the file, but the file name is truncated and when it saves the files it has nothing in it. Though files names that do not have spaces work fine.
Is this a bug in Firefox or is there something wrong in my script that IE is compensating for? Do have to get rid of all spaces in my file names (I fear this is what I may have to do)? Any suggestions? Thank you.
Code: Select all
<?php
if ($num =1) { // If query ran OK, display photo
$val= ($row[0]);
//update ULR to correct location on server
$val = str_replace("\\","/",$val);
$val = str_replace(".JPG",".jpg",$val);
$val = "../image_database/Medium Resolution/".str_replace("C:/local source/","",$val);
$SRC_FILE = $val;//address for photo to download
$download_size = filesize($SRC_FILE);//gets the file size of photo
$filename = ($row[1]); //gets only filename (from database instead of using base())
//download the photo
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: private");
header("Content-Type: image/jpg");
header("Content-Disposition: attachment; filename=$filename");
header("Accept-Ranges: bytes");
header("Content-Length: $download_size");
@readfile($SRC_FILE);
mysql_free_result ($result); // Free up the resources.
mysql_close(); // Close the database connection.
?>