• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multi Upload with CI & swfUpload

#21
[eluser]TheFuzzy0ne[/eluser]
Hi, everyone!

I was having trouble with SWFUpload sending the wrong mime type - so I fixed it!

It's a little dirty, but works nonetheless. You just need to make sure that the GD2 library is installed.

Here's the fix I put inside my controller:
Code:
/**
* SWFUpload passes all files across with a mime type of application/octet-stream
* This method fixes that.
*
* @access protected
* @param string The name of the file input field.
* @return void
*/
protected function _fix_mime_type($field='userfile')
{
    if (isset($_FILES[$field]))
    {
        $size = getimagesize($_FILES[$field]['tmp_name']);

        if ($size)
        {
            $_FILES[$field]['type'] = $size['mime'];
        }
    }
}

Simple call it before you call:
Code:
$this->upload->do_upload();
and all should be well.

I'm sure that this can be implemented within the upload library, but I'm in a terrible rush, and so haven't done so yet.

Hope this helps!

Ciao f'now!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.