codeigniter, jquery

CodeIgniter Uploadify problem


CodeIgniter Uploadify problem

I tried to implement Uploadify with CodeIgniter upload class, and had some issues with recognising proper mime types.

First issue was solved by extending application/config/mimes.php with code:

1 'gif'   =>   array('image/gif','application/octet-stream'),
2 'jpeg'  =>   array('image/jpeg', 'image/pjpeg', 'application/octet-stream'),
3 'jpg'   =>   array('image/jpeg', 'image/pjpeg', 'application/octet-stream'),
4 'jpe'   =>   array('image/jpeg', 'image/pjpeg', 'application/octet-stream'),
5 'png'   =>   array('image/png''image/x-png', 'application/octet-stream'),

You also need to extend Upload.php by uploading this extension:
Download
to application/library

Result from controller should looks like this

1   if ( ! $this->upload->do_upload('Filedata')) {
2                 $error = array('error' => $this->upload->display_errors());
3         } else {
4                 $data = $this->upload->data();
5         }
6 $return = array('name' => $data['file_name'],
7                 'size' => round($data['file_size'] * 100),
8                 'type' => $data['file_type']);
9 echo json_encode(array('Filedata' => $return));
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s