note 19423 deleted from features.file-upload by nlopess
| From: | nlopess@php.net | Date: | Sat, 03 Apr 2004 15:19:06 +0000 |
| Subject: | note 19423 deleted from features.file-upload by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-67574@lists.php.net to get a copy of this message | ||
Note Submitter: jim.dam@sympatico.ca
----
Some browsers label the type differently. I found this out while trying to restrict the file types
that could be uploaded. I created a simple script that will let the user upload a file, and then
print_r() the $_FILES variables. In Microsoft Internet Explorer 6.0.26 on Windows XP, I got this
result:
Array
(
[file] => Array
(
[name] => command.com
[type] => application/octet-stream
[tmp_name] => C:\WINDOWS\TEMP\phpBE.tmp
[size] => 50620
)
)
Uploading the same file with the same script in Opera 6.01 (again on Windows XP), I got this result:
Array
(
[file] => Array
(
[name] => command.com
[type] => application/octet-stream; name="command.com"
[tmp_name] => C:\WINDOWS\TEMP\phpBF.tmp
[size] => 50620
)
)
The tmp_name is obviously supposed to be different, but notice how the name of the file was appened
to type. My solution is either (a) split() at the semicolon and use the first element of that
array, or (b), search the type for the allowed filetypes (via strstr()).