Multi file upload help - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Multi file upload help (/showthread.php?tid=37914) |
Multi file upload help - El Forum - 01-24-2011 [eluser]steviez[/eluser] Hi, I am trying to make codeigniter upload multiple files at once but all i get is errors. My code is this: Code: function do_upload() but all i get when upload is complete is: Quote:Array any ideas? Multi file upload help - El Forum - 03-02-2011 [eluser]Bigil Michael[/eluser] this code will help u.this code is for uploading 6 images at a time controller function manage_image(){ if($this->input->post('Submit')){ for($i=1;$i<=6;$i++) { if($_FILES['photo_'.$i]['name']!=''){ //upload thumbnail $config = array(); $config['upload_path'] = absolute_path().'flashimages/'; $config['allowed_types'] = 'png'; $config['file_name'] = '0'.$i; $config['max_size'] = '1024'; $config['overwrite'] = 'TRUE'; $this->load->library('upload'); $this->upload->initialize($config); if ( ! $this->upload->do_upload('photo_'.$i)) { $data['alert'] = $this->upload->display_errors(); $this->load->view('admin/homepage/add_image', $data); } else { $upload_data = $this->upload->data(); $filename = $upload_data['file_name']; $width = $upload_data['image_width']; $height = $upload_data['image_height']; $config1 = array(); $this->load->library('image_lib'); $config1['source_image'] = absolute_path().'flashimages/'.$filename; if($width>449){ //resize image $sizes = array('width' => $width, 'height' => $height, 'new_width' => 449, 'new_height' => 271); $newsize = array(); $newsize = $this->image_lib->size_calculator($sizes); $config1['maintain_ratio'] = FALSE; $config1['width'] = $newsize['new_width']; $config1['height'] = $newsize['new_height']; $this->image_lib->initialize($config1); $this->image_lib->resize(); $this->image_lib->clear(); } $config1['maintain_ratio'] = FALSE; $config1['width'] = 350; $config1['height'] = 392; $config1['create_thumb'] = TRUE; $config1['thumb_marker'] = 'thumb_'; $this->image_lib->initialize($config1); $this->image_lib->resize(); $this->Homepage_model->save_image('photo_'.$i,$filename); $data['alert'] = 'image uploaded'; } } } }else{ //call view here } } model function save_image($field,$filename=''){ $cid=1; if($filename!=''){ $data[$field] = $filename; } $this->db->where('id',$cid); $this->db->update('home',$data); } |