Welcome Guest, Not a member yet? Register   Sign In
image_width, image_height with flashupload
#1

[eluser]m9dfukc[/eluser]
steps in how to use a fully working flashupload in codeigniter

if you are using flash to upload pictures - as an example with swfupload you will experience some trouble because flash doesn't use a correct image mime format. If you whant to get it to work you have to add 'application/octet-stream’ in your mimes.php:

Code:
'gif'    =>    array('image/gif', 'application/octet-stream'),
'jpeg'   =>    array('image/jpeg', 'image/pjpeg', 'application/octet-stream'),
'jpg'    =>    array('image/jpeg', 'image/pjpeg', 'application/octet-stream'),
'jpe'    =>    array('image/jpeg', 'image/pjpeg', 'application/octet-stream'),
'png'    =>    array('image/png',  'image/x-png', 'application/octet-stream'),

now image uploading with flash works but you don't have access to the image_width and image_height from your $this->upload->data();. codeigniter checks in the upload class if the uploaded file is a image but because of the 'wrong' image mime type which flash sends you have to modify the CI_Upload class:

Normal is_image function:
starts at line 479
Code:
function is_image()
{
     $img_mimes = array(
            'image/gif',
            'image/jpg',
            'image/jpe',
            'image/jpeg',
            'image/pjpeg',
            'image/png',
            'image/x-png'
              );


     return (in_array($this->file_type, $img_mimes, TRUE)) ? TRUE : FALSE;
}

change to:

Code:
function is_image()
{
     $img_mimes = array(
            'image/gif',
            'image/jpg',
            'image/jpe',
            'image/jpeg',
            'image/pjpeg',
            'image/png',
            'image/x-png',
            'application/octet-stream'
              );


     return (in_array($this->file_type, $img_mimes, TRUE)) ? TRUE : FALSE;
}

now you will have access to image_width and image_height and do further calculations with that values.

but be aware this modification opens up your system for all types of code and could be abused for hacking your system so only use that mod if you know what you are doing!

best m9d...




Theme © iAndrew 2016 - Forum software by © MyBB