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 have a bit of code that changes the name of a file upload. The code executes perfectly on firefox but for some reason fails to execute on IE, Safari, Opera. I have failed to find a reason why it fails to execute on these browsers. Any help would be greatly appreciated.
Have just checked the mime types again, and nothing appears to be out of place. To check if it was the mime type, i changed it to allow upload of jpg instead of msword, and again it failed to execute in the browsers listed.
Having taken this element of the code out of the script, it processes in all browsers. However, this coding is a necessary part of the script as it renames the uploaded file primarily to avoid file overwrite problems where users inadvertently upload files with the same name.
I'd be grateful for any further input to try to solve this.
phpnoobyyy wrote:No joy...I'm tearing my hair out!
Post your updated code. When someone suggests somethiong and it doesn't work you should post exactly what you have tried so we are all on the same page.
1. Internet Explorer 7 uploads Word (.doc) files as "application/octet-stream".
2. Using unfiltered user input to define file names is not a good idea.
3. Use pathinfo($path, PATHINFO_EXTENSION) or substr(strrchr($path, '.'), 1) to get the file extension.
4. I would use the date format "Ymd" or "Y-m-d" or "YmdHis" for files so they will be sorted chronologically when sorted alphabetically and the date will always have a fixed length.
5. The $target string has no trailing slash and the string returned by basename() has no leading slash, so there is no slash between the $target and basename. That variable isn't used, so I guess it doesn't matter.
6. In addition to the two John mentioned, add to the list of garbage variables $target and $ok.
Edit: This post was recovered from search engine cache.