note 41615 added to features.file-upload
| From: | steve dot criddle at crd-sector dot com | Date: | Fri, 16 Apr 2004 15:43:44 +0000 |
| Subject: | note 41615 added to features.file-upload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-68214@lists.php.net to get a copy of this message | ||
IE on the Mac is a bit troublesome. If you are uploading a file with an unknown file suffix, IE
uploads the file with a mime type of "application/x-macbinary". The resulting file
includes the resource fork wrapped around the file. Not terribly useful.
The following code assumes that the mime type is in $type, and that you have loaded the file's
contents into $content. If the file is in MacBinary format, it delves into the resource fork
header, gets the length of the data fork (bytes 83-86) and uses that to get rid of the resource
fork.
(There is probably a better way to do it, but this solved my problem):
if ($type == 'application/x-macbinary') {
if (strlen($content) < 128) die('File too small');
$length = 0;
for ($i=83; $i<=86; $i++) {
$length = ($length * 256) + ord(substr($content,$i,1));
}
$content = substr($content,128,$length);
}
----
Manual Page -- http://www.php.net/manual/en/features.file-upload.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41615
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41615&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41615&report=yes
Search -- http://master.php.net/manage/user-notes.php