I'm trying to upload a file and overwrite if exists on server but I always get error msg like:
"File exists, overwrite is FALSE, could not save over file ./uploads/avatars/1.jpg"
Here is my code where 'overwrite' is TRUE... Any idea how to solve this?
Code:
if( isset($_FILES['userfile']['name']) ) {
if( $_FILES['userfile']['name'] != "") {
$config['upload_path'] = 'uploads/avatars/temp/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['remove_spaces'] = true;
$config['overwrite'] = true;
$config['encrypt_name'] = true;
$config['max_size'] = '3000';
$config['max_width'] = '3000';
$config['max_height'] = '3000';
$this->load->library('upload', $config);
if (!$this->upload->do_upload('userfile')) {
// Failed
$error = array('error' => $this->upload->display_errors());
print_r($error);
exit();
} else {
// Success
$image = $this->upload->data();
var_dump( $image );
}
}
}