Sorry, I don't know how to write a title for this that would be very descriptive. Here's the issue. I have a <input type="file> on a php page where a user can browse and upload a file. I then have the page make a directory (that is the same name as the file) and upload the file into that directory at the same time putting the name of the directory and the name of the file in a MySQL database. With me so far?
Microsoft office has an array of programs such as power point, word, outlook, etc... These programs tend to "auto correct" or "adjust" certain texts. For example, if you were to type the number 1, a space, a dash and then another space you will find (in Arial anyway) that once you hit the second space it lengthens the dash.

In my issue someone I know took their power point file and copied the title inside of the file (which had one of these longer dashes) and saved their file with that name. This file was then uploaded and the longer dash caused Internet Explorer to not be able to pull it up for download.

Does anyone have any advice that they can offer as far as how to handle this issue?

Other forums I've posted this question in:
http://forums.devshed.com/php-development-5/php-filename-dash-problem-586464.html
http://forums.codewalkers.com/php-coding-7/php-filename-dash-problem-918254.html
http://www.sitepoint.com/forums/showthread.php?p=4127639#post4127639

    rewrite all file names removing\replacing all ilegal characters, can be done with regular expressions,

    $safe_name=preg_replace("/[^a-z0-9\.]/i","",$unsafe_name);
    

    there are legal characters that would strip out, but its up to you what you want to allow.

      Um why would you past it to 4 forums? all that does is anoy people.

        Because he/she has a better chance of getting an answer...i mean seriously half of these forums suck...if your new or something people suck and like dont answer...god im like so pist lol

          however its called cross posting and considered bad manners, at least wait to see if you get a response. If you ask some one on the street for the time, do you wait for them to tell you the time or walk of and ask another person instantly.

          We are not paid, we chose to help or not. If you don't like not geting a response, pay someone.

            dagon;10900695 wrote:

            rewrite all file names removing\replacing all ilegal characters, can be done with regular expressions,

            $safe_name=preg_replace("/[^a-z0-9\.]/i","",$unsafe_name);
            

            there are legal characters that would strip out, but its up to you what you want to allow.

            • So is it possible to rename the file before uploading it?
            • Is there a list of characters somewhere that I can refer to that are illegal?
            • As far as the cross posting I was always encouraged by forum moderators and admins to cross post as long as the url's are posted . It is sincerely not my intention to annoy people in any way.

              -you rename it after upload

              -There will be a rfc spec, but does every os\browser etc follow it? i would play it safe unless you have a good reason not to, you can encode urlencode() what's left if need be

              -If you say so.

                So, things I'm looking up are preg_replace and urlencode. Thanks for the help!

                  Write a Reply...