We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10487 MODX Staff
    • 1,535 Posts
    This is an auto-generated support/comment thread for FileUpload.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    This snippet allows users to upload files to the webserver.
      Garry Nutting
      Senior Developer
      MODX, LLC

      Email: [email protected]
      Twitter: @garryn
      Web: modx.com
      • 27088
      • 11 Posts
      Shocking_blue Reply #2, 20 years ago
      File upload using Mozilla Firefox can fail when the filename contains international characters

      When uploading a file that has international characters using Mozilla Firefox, the uploaded file may have an altered name (for example, underscore instead of some characters) with a file size of 0.

      I understand this to be related to the way Mozilla handles fileupload in their browsers as I don’t have a problem getting the file uploaded with IE. Having searched the Internet for a solution I came up empty-handed. I did however come across some php code that is essentially the way I am using this snippet as well. But alas they got it wrong as well, their code doesn’t include a check for file-size = 0 allowing the file to be uploaded without any actual data.

      Any one found a solution to this before and care to share. Thanks.

      SB
        • 27088
        • 11 Posts
        Shocking_blue Reply #3, 20 years ago
        no one had to upload files with filenames that contain international characters using Firefox before then?
        come on some one must have had problems with unicode filenames before. just a hint, a push in the general right direction or a link to an article is all i am looking for. i’d fix it if i just knew where to look first...

        it just seems unfair to tell the user they can use any browser they want as long as it is IE tongue
        who is willing to help make this great snippet even better by adding unicode support to it?

        thanks -- SB
          • 19726
          • 239 Posts
          Somehow I missed this post.
          If you can provide me with a file that causes problems I can have a look at it.
            • 27088
            • 11 Posts
            Thanks for getting back to me on this Mitch. The file that causes problems is just a mock-up zip archive with a fictitious name to include international characters. The error message (size is 0 bytes) reported by the FileUpload snippet is: ’sangirdamak.zip is invalid.’ This is as a result of the file having an altered name with a file size of 0.

            Commenting out lines 195 - 199 (checking for file-size = 0) will allow for an empty file with altered name being created in the upload folder. But that is no good of course. The original file name is ’şanğırdamak.zip’ and is 89 bytes. I have attached it to this post.

              • 27088
              • 11 Posts
              tongue LOL I kinda thought this might happen, I used FF to attach the zip file ’şanğırdamak.zip’ to my previous post but this is a problem with Mozilla and not so much with the code of the snippet as even SMF is creating a zero-bytes file with altered name.

              Thus this time I write this post in IE and attach the file that way. I guess I really need to go and ask about this at MozillaZine and let the SMF people know that attaching zero-bytes attachments is not being checked at their forum software  wink

              EDIT: SMF forum software latest release (RC3) has unicode support and is attaching below file correctly. I guess I will have a dig around their source code to come up with a solution.
                • 19726
                • 239 Posts
                I was able reproduce the problem by renaming a file to "şanğırdamak.zip" (copy/pasted the name from the forums).
                The strange thing is that when you press the "Browse..." button and select the file everything seems to be OK, but when you press "Open" the name that is displayed in the editbox will be "sangirdamak.zip". This might be causing the problem.

                I hope to have some time later this week to have a look at this.
                  • 19726
                  • 239 Posts
                  Sorry for the late reply on this. I had a look into this issue, but I can’t find anything wrong with the snippet. Uploading the same file to other sites causes the same issue which makes me believe it is not an issue with the snippet. I think we are hitting the following FF bug.

                  https://bugzilla.mozilla.org/show_bug.cgi?id=342052

                  So I guess I can’t make a fix for it in the snippet
                    • 27088
                    • 11 Posts
                    Quote from: Shocking_blue at Oct 09, 2006, 02:37 PM

                    ... but this is a problem with Mozilla and not so much with the code of the snippet as even SMF is creating a zero-bytes file with altered name.
                    Thanks for looking into this Mitch. I guess I came more or less to the same conclusion, as you did, in one of my previous posts. I also remember reading something on the W3C site that mentioned that if the file name of the sender’s operating system is not
                    in US-ASCII, the file name might be approximated. I guess that’s what FF is doing; I wonder though if one would change one’s system locale whether FF would behave accordingly too? Must try this out sometime but right now I am limited for time.

                    SB
                      • 18503
                      • 45 Posts
                      Is there a way to restrict what characters are allowed in the uploadable file name?

                      Like if I wanted to only allow files with numbers and letters in their name, no special characters

                      Or wanted to disallow files with certain characters in them?
                        -dan
                        http://wylio.com
                        Wylio - Pictures for Bloggers