note 19423 added to features.file-upload
| From: | jim dot dam at sympatico dot ca | Date: | Wed, 27 Feb 2002 01:13:42 +0000 |
| Subject: | note 19423 added to features.file-upload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-27106@lists.php.net to get a copy of this message | ||
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()).
--
http://www.php.net/manual/en/features.file-upload.php
http://master.php.net/manage/user-notes.php?action=edit+19423
http://master.php.net/manage/user-notes.php?action=delete+19423
http://master.php.net/manage/user-notes.php?action=reject+19423