note 14809 deleted from features.file-upload by irc-html

From: Date: Sat, 19 Jan 2002 20:35:31 +0000
Subject: note 14809 deleted from features.file-upload by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25367@lists.php.net to get a copy of this message
There is a problem when trying to upload a jpg or gif from a mac. the problem seems to be that when you upload a file format that the browser doesn't recognize, it tends to automatically class it as the mime type 'application/x-macbinary'after looking at the files, i have come to the conclusion that with this standard MacBinary format (NOT the compressed version) all that is added is a simple header. this can be got rid of and the file can ran as normal. try this little function out, it strips the 128 byte header from the file function convertmacbin($filename) { $fp = fopen($filename,'r'); fseek($fp,128); $data = fread($fp,(filesize($filename)-128)); fclose($fp); $fp = fopen($filename,'w'); fwrite($fp,$data); fclose($fp); } if ($filename_type == "application/x-macbinary") { // let's strip 128 bytes off the file convertmacbin($filename); } This code assumes that your form input for the file is named 'filename', like this: <FORM NAME="the_form" ENCTYPE="multipart/form-data" METHOD=POST ACTION="somephp.php"> File Name: <INPUT NAME="filename" TYPE="file"><BR> <INPUT TYPE="submit" VALUE="submit"> </FORM>

« previous php.notes (#25367) next »