i have a problem when i do an upload of an image from the multi part form created for a dashboard. All is working good, i found the new image data saved on his table in the database, but i don't found the uploaded images in the uploads dir.
This is the controller:
public function dashboard() {
$this->bc ='Backend';
$this->id = 1;
$this->add ='index';
$local = $this->Login_model->getInfo();
$err ='';
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->library('upload');
$check = $this->input->post('act');
if( $check == 'local' ){
$this->form_validation->set_rules('title', 'title', 'required');
$this->form_validation->set_rules('city', 'city', 'required');
$this->form_validation->set_rules('postalcode', 'postal code', 'required');
$this->form_validation->set_rules('street', 'street', 'required');
$this->form_validation->set_rules('email', 'email', 'required');
$this->form_validation->set_rules('metadescription', 'metadescription', 'required');
$this->form_validation->set_rules('metakey', 'metakey', 'required');
$this->form_validation->set_rules('fadescription', 'fadescription', 'required');
if( $this->form_validation->run() == FALSE )
{
}
else
{
unset($_POST['act']);
unset($_POST['id']);
$id = 1;
$result = $_POST;
$this->load->model('Login_model','model');
$in_id = $this->model->updateLocal($result,$id);
$allowedExts = array("gif", "jpeg", "jpg", "png", "JPG");
$config['upload_path'] = './uploads/';
if( isset($_FILES['files']['name']) && ( count($_FILES['files']['name']) > 0 ) ){
for( $i=0; $i < count($_FILES['files']['name']); $i++ ){
if($_FILES['files']['name'][$i] !=""){
$temp = substr($_FILES['files']['type'][$i], strpos($_FILES['files']['type'][$i], "/") + 1);
$extension = $temp;
if ((($_FILES['files']['type'][$i] == 'image/gif')
|| ($_FILES['files']['type'][$i] == 'image/jpeg')
|| ($_FILES['files']['type'][$i] == 'image/jpg')
|| ($_FILES['files']['type'][$i] == 'image/JPG')
|| ($_FILES['files']['type'][$i] == 'image/pjpeg')
|| ($_FILES['files']['type'][$i] == 'image/x-png')
|| ($_FILES['files']['type'][$i] == 'image/png'))
&& in_array($extension, $allowedExts)) {
if ($_FILES["files"]["error"][$i] > 0) {
} else {
$names[$i] = time().$_FILES['files']['name'][$i];
move_uploaded_file($_FILES['files']['tmp_name'][$i], $config['upload_path'], $names[$i] );
if($i == 0 ){
$this->model->insertImg($names[$i],$id,1);
}else{
$this->model->insertImg($names[$i],$id,0);
}
}
} else {
}
}
}
}
$this->session->set_flashdata('success','Information updated');
redirect('backend/dashboard');
}
}
$out = $this->load->view('backend/dashboard',array('err'=>$err),true);
$this->load->view('backend/dashboard',array('content'=>$out,'local' =>$local));
}