CodeIgniter Forums
Flash Image Uploader Issue - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Flash Image Uploader Issue (/thread-21637.html)



Flash Image Uploader Issue - El Forum - 08-16-2009

[eluser]brainer[/eluser]
Hi guys, I've ran into a bit of an issue while trying to implement my flash image uploader to codeigniter. Its worked on previous apps, but not this one. I've searched the forums, but all i found was Uploadify, SWFUploader and CI session issues.

The progress bar runs, but the file just doesnt get placed. The folder has full write permissions and i've allowed the mime types

Code:
'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')

Here's my controller:

Code:
function ddPieceUploaderImage()
    {
        $config['upload_path'] = "uploads/";
        $config['allowed_types'] = 'gif|jpg|jpeg|png';
        $config['max_size'] = '1000';
        $config['max_width'] = '1920';
        $config['max_height'] = '1280';
        
        $this->load->library('upload', $config);
        
        if(!$this->upload->do_upload()) echo $this->upload->display_errors();
        else {
            $fInfo = $this->upload->data();
            $this->_createThumbnail($fInfo['file_name']);
            
            $data['uploadInfo'] = $fInfo;
            $data['thumbnail_name'] = $fInfo['raw_name'] . '_thumb' . $fInfo['file_ext'];
            $this->load->view('upload_success', $data);    
        }
    }
    
    
    
    function _createThumbnail($fileName) {
        $config['image_library'] = 'gd2';
        $config['source_image'] = 'uploads/' . $fileName;    
        $config['create_thumb'] = TRUE;
        $config['maintain_ratio'] = TRUE;
        $config['width'] = 75;
        $config['height'] = 75;
        
        $this->load->library('image_lib', $config);
        if(!$this->image_lib->resize()) echo $this->image_lib->display_errors();
    }


Has anyone come accross this issue before?


Flash Image Uploader Issue - El Forum - 08-16-2009

[eluser]tomcode[/eluser]
I've built my flash uploader by disabling CI's mime-type check. I extended the upload library by overriding the method is_allowed_filetype().

Code:
/**
* Overrides CI's default, checks no longer
* the mime types, only the file extension.
* I recommend additional checks to compensate.
*
*/
function is_allowed_filetype()
{
    if (count($this->allowed_types) == 0 OR ! is_array($this->allowed_types))
    {
        $this->set_error('upload_no_file_types');
        return FALSE;
    }
        
    foreach ($this->allowed_types as $val)
    {
        if($val == trim($this->file_ext, ".")) return TRUE;
    }

    return FALSE;
}



Flash Image Uploader Issue - El Forum - 08-16-2009

[eluser]brainer[/eluser]
thank you for your help... it turns out im a complete idiot. I've been sitting here for 5 hours and it turns out I didn't have the uploader route defined... AND then that permissions weren't actually set.

sorry.


Flash Image Uploader Issue - El Forum - 08-16-2009

[eluser]tomcode[/eluser]
Glad You found out. No need to be sorry.

I'll use this opportunity to review my own uploader, I never felt very comfortable with my solution...