Wednesday, 2 October 2013

Error when uploading a big image with CodeIgnitor

Error when uploading a big image with CodeIgnitor

I try to upload big images (>~1.5MB) to my website using PHP but the file
dont appear on the server. Sometimes I get Error 1 (Max size exceeded).
Is there anything I can do?
public function do_upload($field) {
$config['upload_path'] = './uploads/';
$config['max_size'] = '100000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if (!$this->upload->do_upload($field)) {
$error = array('error' => $this->upload->display_errors());
return $error;
} else {
/*$data = array('upload_data' => $this->upload->data());
return $data;*/
$updata =$this->upload->data();
$data = $updata['raw_name'].$updata['file_ext'];
return $data;
}
}
Here can I call the function:
$pic = $this->do_upload('inputUpProfile');
Here I save the picture to the database:
if ($this->input->post('post') == ''){
$type="image";
} else {
$type="image-with-text";
}
} else {
$pic = "";
$type = "text";
}
$result = $this->blog->addPost($_SESSION['user_id'], $type ,
$this->input->post('post'),$pic);
}
Models:
function addPost($user_id, $post_type, $post , $pic ) {
$today = date("Y-m-d H:i:s");
$vales = array('ev_user_id' => $user_id, 'ev_type' => $post_type,
'ev_text' => $post,'ev_pic' => $pic, 'ev_date' => $today);
$this->db->insert($this->table_name, $vales);
}
The error:
Error Number: 1054
Unknown column 'Array' in 'field list'
INSERT INTO events (ev_user_id, ev_type, ev_text, ev_pic, ev_date) VALUES
(1, 'image', '', Array, '2013-10-02 23:32:50')

No comments:

Post a Comment