• 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!


Messages In This Thread
Multi Upload with CI & swfUpload - by El Forum - 02-03-2008, 11:47 AM
Multi Upload with CI & swfUpload - by El Forum - 02-03-2008, 01:54 PM
Multi Upload with CI & swfUpload - by El Forum - 02-06-2008, 05:54 PM
Multi Upload with CI & swfUpload - by El Forum - 02-29-2008, 05:12 PM
Multi Upload with CI & swfUpload - by El Forum - 03-04-2008, 03:41 PM
Multi Upload with CI & swfUpload - by El Forum - 04-04-2008, 09:34 PM
Multi Upload with CI & swfUpload - by El Forum - 06-07-2008, 05:31 PM
Multi Upload with CI & swfUpload - by El Forum - 06-13-2008, 12:01 AM
Multi Upload with CI & swfUpload - by El Forum - 06-13-2008, 12:37 AM
Multi Upload with CI & swfUpload - by El Forum - 06-13-2008, 12:58 AM
Multi Upload with CI & swfUpload - by El Forum - 06-13-2008, 05:36 AM
Multi Upload with CI & swfUpload - by El Forum - 06-13-2008, 05:36 AM
Multi Upload with CI & swfUpload - by El Forum - 06-13-2008, 09:18 AM
Multi Upload with CI & swfUpload - by El Forum - 06-13-2008, 09:39 AM
Multi Upload with CI & swfUpload - by El Forum - 06-25-2008, 11:06 PM
Multi Upload with CI & swfUpload - by El Forum - 10-01-2008, 07:55 AM
Multi Upload with CI & swfUpload - by El Forum - 10-08-2008, 12:40 PM
Multi Upload with CI & swfUpload - by El Forum - 10-08-2008, 05:03 PM
Multi Upload with CI & swfUpload - by El Forum - 04-27-2009, 07:37 AM
Multi Upload with CI & swfUpload - by El Forum - 04-27-2009, 01:33 PM
Multi Upload with CI & swfUpload - by El Forum - 09-25-2012, 09:41 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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