Just Another Blog

Are you thinking what I'm thinking?

Monday, August 08, 2005

Firefox (for Windows)-specific file upload problem

I was writing a simple PHP script for handling file upload. I found that some files that I uploaded with Firefox are 0 bytes in size (it should be non-zero). Since I developed it under a Chinese (simpified) Windows, I found this problem rather ridicious: I can't upload a file named with certain simpified Chinese characters!

Let's illustrate with the following example:

  1. Create a dummy file with dummy content.
  2. Rename it so that it contains the character , e.g. 高达 (Gundam).
  3. Upload them using a HTML form (encoded in UTF-8).

The result in PHP (by using print_r $_FILES;):

Array
(
    [attachment] => Array
        (
            [name] => Array
                (
                    [0] => print.pdf
                    [1] => 高_seed.pdf
                    [2] => 
                    [3] => 
                    [4] => 
                )

            [type] => Array
                (
                    [0] => application/pdf
                    [1] => application/octet-stream
                )

            [tmp_name] => Array
                (
                    [0] => C:\WINDOWS\TEMP\php17F.tmp
                    [1] => C:\WINDOWS\TEMP\php180.tmp
                )

            [error] => Array
                (
                    [0] => 0
                    [1] => 0
                )

            [size] => Array
                (
                    [0] => 31527
                    [1] => 0
                )

        )

)

See? The character was replaced with a underscore _, and the file size is zero. The file upload was success since the error codes are 0s.

Obviously Firefox can't find the file (can't resolved the path?), so it uploads nothing to the server. I guess it is another time to file a bug in the famous bugzilla database. ;-)

Edited: it seems that the bug was already filed by someone else.

Edited again: anyway, I filed the bug, although it seems that no one noticed yet. :-(

0 Comments:

Note that troll and spam comments will be deleted without any notification.

Post a Comment

<< Home