While implementing jQuery FileUpload in CodeIgniter everything seems to work, no javascript errors and the files get created in the default folders (chmod'ed 0777), but there are two issues.
1. I can't override the default options on the PHP handler provided by the package. Here is the Controller action I'm using to do so, none of the parameters passed are actually applied, if I dump the options within the UploadHandler I get the default options.
public function fileupload()
{
if ($this->input->is_ajax_request())
{
# load library
$this->load->library('UploadHandler');
# upload file
$upload_handler = new UploadHandler(array(
'upload_dir' => FCPATH.'upload/realty/'.$this->_user->id.'/',
'mkdir_mode' => 0777,
'accept_file_types' => '/\.(gif|jpe?g|png)$/i',
));
}
else
{
redirect('error/page_not_found');
}
}
2. The script is throwing a error when a file finishes uploading :
SyntaxError: Unexpected token {
Here is the response of an example request :
{"files":[{"name":"nebula-ngc-281.jpg","size":590295,"type":"image\/jpeg","url":"http:\/\/test.filipematias.info\/mercadoimobiliario\/admin\/files\/nebula-ngc-281.jpg","thumbnailUrl":"http:\/\/test.filipematias.info\/mercadoimobiliario\/admin\/files\/thumbnail\/nebula-ngc-281.jpg","deleteUrl":"http:\/\/test.filipematias.info\/mercadoimobiliario\/admin\/?file=nebula-ngc-281.jpg","deleteType":"DELETE"}]}{"files":[{"name":"nebula-ngc-281 (1).jpg","size":0,"type":"image\/jpeg","error":"File upload aborted","deleteUrl":"http:\/\/test.filipematias.info\/mercadoimobiliario\/admin\/?file=nebula-ngc-281%20%281%29.jpg","deleteType":"DELETE"}]}