MY_Upload to work with Flash-Uploads (application/octet-stream) |
[eluser]Christian Rößler[/eluser]
i saw som threads about this earlyer but wanted to post a complete description to handle the issue. so here it is: Put this code into a new file called 'MY_Upload.php' into application/librarys! Code: <?php What you also need to do is adding the application/octet-stream into Code: application/config/mimes.php Code: $mimes = array( 'hqx' => 'application/mac-binhex40',
[eluser]Christian Rößler[/eluser]
The only thing left is to determine whether the uploaded file is a image. I want to do this by opening the uplaoded file and read in the first few bytes and compare them with well known jpg + png + ... headers. I could need help in this point ;-) Feel free to modify this lib or give me some improvement-hints or tips how to 100% determine whether i have uploaded an image. Here is a example usage: (regard the additional+new parameter in the config-array and the extra parameter in do_upload()) Code: public function index() Later on you are able to process to uploaded file (image) via the image lib as follows: (There is no magic code going on here. do it as described in the docs!) Code: // get an array containing all of the data related to the file i've uploaded
[eluser]Ignacio[/eluser]
Good good, excelent. But I don't know why, I'm uploading a jpg pic and FileType retrieve me image/png. The problem is here: Code: if (in_array($this->file_type, $png_mimes)) Any way to solve this?
[eluser]Ignacio[/eluser]
I did a hack for the upload library, I'm getting the filetype with exif data (exiftool), check this: http://ellislab.com/forums/viewthread/76751/
[eluser]kallus[/eluser]
I wrote a couple of lines of code that uses fileinfo to identify a more specific mime type for files of type application/octet-stream, maybe someone finds it useful. http://ellislab.com/forums/viewthread/81308/ |
Welcome Guest, Not a member yet? Register Sign In |