PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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.
BZorch wrote:
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.
Try doing a str_replace on space characters and converting them to %20. Urls cannot contain spaces, while %20 (the urlencoded version of space) is legal.
No luck. I tested to make sure that the spaces were replaced with %20 by printing the variable and it is replacing it correctly, but Firefox still truncates and IE shows it as an empty space. Thanks.
BZorch wrote:No luck. I tested to make sure that the spaces were replaced with %20 by printing the variable and it is replacing it correctly, but Firefox still truncates and IE shows it as an empty space. Thanks.
Do you have a link where I can test and see what it does?
Since the site is underdevelopment I am reluctant to give out the links to a particular page. Because of this you may not be able to help.
I was surprised that no one else is having this problem. Of course, everyone may have known to not include spaces in their filenames. I just may have to rename 7,000+ files.
The following is a little more description of what happens in Firefox.
Basically I have a link that says "Download Large File"
When selected the download dialogue comes up asking to open or save the file. The file name it shows in Firefox includes all letters in the filename up to the first white space. When I click to download, it downloads a file with nothing in it named the truncated file name.
Example1: 34th Street-001.jpg Becomes(Firefox): 34th Becomes(IE and Opera):34th Street-001.jpg
Example2: Misc-001.jpg Becomes(Firefox) Misc-001.jpg Becomes(IE and Opera):Misc-001.jpg
BZorch wrote:I was surprised that no one else is having this problem. Of course, everyone may have known to not include spaces in their filenames. I just may have to rename 7,000+ files.
Thats why I want to see some example code that produces the effect.
I have plenty of filenames with spaces in them that Firefox links correctly - as long as they are converted to %20's first.
Since Firefox is "working for me", and not for you, I can only think there is something wrong in the implementation, and not in the concept.
I finally found some time to try your suggestions.
Adding the quotes worked!
Thanks to you both for your help.
BTW I can not find a good resource that explains all of the header information used. Does anyone know of a good tutorial for using headers? The PHP site is not very descriptive. As to what each element is or all of the choices. I would just like to learn a bit more because they seem like they can be very useful.