how to upload two files on same form different path in codeigniter

Solutions on MaxInterview for how to upload two files on same form different path in codeigniter by the best coders in the world

showing results for - "how to upload two files on same form different path in codeigniter"
Max
19 Feb 2017
1if($this->input->post('Submit')){
2
3//-----------Image File Section Start Here -----------//
4
5 $config['upload_path'] = './uploads/';   // Directory 
6$config['allowed_types'] = 'jpg|jpeg|bmp|png';  //type of images allowed
7$config['max_size'] = '30720';   //Max Size
8$config['encrypt_name'] = TRUE;   // For unique image name at a time
9
10$this->load->library('upload', $config);  //File Uploading library
11$this->upload->do_upload('userfile');  // input name which have to upload 
12$video_upload=$this->upload->data();   //variable which store the path
13
14//--------------End of Image File  Section------------------------//
15
16
17
18//---------Thumbnail Image Upload Section Start Here -----------//
19
20$config2['upload_path'] = './thumb/';   // Directory 
21$config2['allowed_types'] = 'jpg|jpeg|bmp|png'; //type of images allowed
22$config2['max_size'] = '30720';   //Max Size
23$config2['encrypt_name'] = TRUE;   // For unique image name at a time
24
25
26$this->upload->initialize($config2); //we can not use upload library again and again it will not initialize again and again so thats why i have used initialize 
27$this->upload->do_upload('txt_thumb');  // File Name
28$thumbnail_upload=$this->upload->data(); // store the name of the file 
29
30//--------End of Thumbnail Upload Section-----------//
31
32
33
34    $date=date("d-m-Y");  // Store current date in variable 
35
36   // Here the database query to insert
37
38    $data = array(
39    'parent_id'=> $this->input->post('txt_parent'),
40    'cat_id' => $this->input->post('txt_category'),
41    'title'=> $this->input->post('txt_title'),
42    'status' => $this->input->post('txt_status'),
43    'featured' => $thumbnail_upload['file_name'],
44    'image' => $video_upload['file_name'],
45    'time'=>$date
46    );
47
48       $sql_ins= $this->Insimage->insertimage($data);
49       if($sql_ins)
50       {
51           $data['Success'] = "Image has been succesfully inserted!!";
52       }
Guillaume
13 Sep 2017
1    private function upload_files($path, $title, $files)
2    {
3        $config = array(
4            'upload_path'   => $path,
5            'allowed_types' => 'jpg|gif|png',
6            'overwrite'     => 1,                       
7        );
8
9        $this->load->library('upload', $config);
10
11        $images = array();
12
13        foreach ($files['name'] as $key => $image) {
14            $_FILES['images[]']['name']= $files['name'][$key];
15            $_FILES['images[]']['type']= $files['type'][$key];
16            $_FILES['images[]']['tmp_name']= $files['tmp_name'][$key];
17            $_FILES['images[]']['error']= $files['error'][$key];
18            $_FILES['images[]']['size']= $files['size'][$key];
19
20            $fileName = $title .'_'. $image;
21
22            $images[] = $fileName;
23
24            $config['file_name'] = $fileName;
25
26            $this->upload->initialize($config);
27
28            if ($this->upload->do_upload('images[]')) {
29                $this->upload->data();
30            } else {
31                return false;
32            }
33        }
34
35        return $images;
36    }
37
queries leading to this page
upload multiple image codeigniter 3same image upload path to database codeignitercodeigniter upload multi file with different namehow to upload multiple files in codeignitermultiple files upload codeigniter ajaxcodeigniter 4 multiple image uploadmultiple image upload code in codeignitercodeigniter 3 multiple file upload 28array 29multiple file upload in codeigniter 3multiple image upload in codeigniter using ajaxmultiple image upload in codeigniter 3multiple file upload in api codeigniterupload more than one file codeigniterupload multiple image files in codeignitermultiple image upload in codeigniter with database examplecodeigniter do multi uploadcodeigniter multiple uplozdmulti image upload in codeignitercodeigniter multiple uploadmulti upload codeignitermultiple file upload in codeignitermultiple file upload codeigniter 3codeigniter multiple image upload2 file field in codeignitermultiple files download ajax codeignitermultiple file uploading in codeignitermultiple image upload in codeigniter 3 using ajaxi am upload multiple file but same file upload multiple time in codeigniterupload multiple files jquery codeigniterhow to upload image with multiple path in codeigniterupload two files in codeignitercodeigniter upload multiple imagescodeigniter 3 single file uploadmultiple file upload in cijs multiple file upload codeigniter democodeigniter attach multiple filescodeigniter multiple file upload 28array 29upload multiple file codeignitercodeigniter upload multipart filehow to get multiple files in postman codeignitermultiple image upload in codeigniter with database demoupload 2 file at a time using different location codeignitercodeigniter upload multiple file different directoryupload multiple file in different folder location in codeignitermultiple file upload in codeigniter using databaseupload multiple input image php codeignitercodeigniter mulstiple file upload2 file upload chhsee in codeignitermultiple file upload in codeigniter using ajaxmultiple file upload not working codeigniterfilepond multiple file upload codeigniter 3upload file dengan ajax codeignitercodeigniter multiple file upload ajaxmultiple file upload on codeigniterupload 2 input codeigniterupload 2 file with two different config in codeignitermulti image upload sql codeigniterupload multiple file codeigniter 3 with upload librarycodeigniter multiple file upload easymultiple image upload codeignitercodeigniter two image uploadcodeigniter 3 upload multiple filesupload multiple files on codeigniterupload multiple file codeigniter 3multiple upload file codeigniter 3set upload path to two different folders in codeigniterupload multiple files in php codeigniter input file multiplehow to upload multiple files in codeignitercodeigniter3 upload multiple file different directory lcodeigniter multi file uploadmultiple files upload codeigniterjs multiple file upload codeigniterhow to uplaod multiple files in codeigniterhow to upload multiple images in codeignitercodeigniter 3 upload multiple files in for loop 5bhow to upload multiple image in codeigniterfile upload in codeignitercodeigniter 3 multiple file upload 28array 29 githubcodeigniter handling multiple file upload2 file upload in codeigniterupload library in codeigniter use for multiple timesupload multiple file filepond codeigniter 3upload multiple foto and file codeignitercodeigniter multiple file uploadscript multiple file upload code codeigniter 4multiple file attach in codeigniter live demohow to upload multiple files rest api in codeigniter and store in databasehow to upload two different files in codeignitermultiple image upload in codeigniter with database source codemultiple file uploadafter login codeignitermultiple images upload in codeigniter using databaseupload multiple files php codeignitermultiple file upload in codeigniter crud functioncodeigniter 3 multiimage uploadmultiple image upload in codeigniter step by stepmultiple image upload in php codeignitercodeigniter file upload with file full path database savemultiple file upload with codeigniter 3upload file codeigniterupload multiple codeigniter 3do upload codeigniter multipledownload multiple files ajax codeignitermultiple image upload to server in codeigniterupload file in codeignitermultiple image upload in codeigniterupload multiple file in codeigniter with add more optionupload 2 file in different directory codeigniterci multiple file uploadcodeigniter file upload multiple filesmultiple files upload in codeignitermultiple image upload in codeigniter web servicehow i can upload more than one file in codeigniter 3code igniter do upload multiplemultiple file file upload in codeigniter live demohandle two upload fields in a single form codeignitersame upload path in database codeignitermulti file upload in codeignitercodeigniter 4 multiple file uploadcodeigniter 3 php upload multiple filescodeigniter upload multiple fileshow to upload multiple file in codeignitercodeigniter multi uploadupload files from multiple field codeignitermulti upload file codeigniterhtml for multiple file upload in codeignitermultiple upload file codeignitermultiple file attach in codeignitercodeigniter upload multiple file typecodeigniter multiple image upload with preview 24this 3eload 3elibrary 28 27upload 27 2c 24config 2c multilpe uploadmultiple image upload in codeigniter with databasehow can i create multiple config array for file upload in codeigniterhow to get multiple file upload value in codeigniterupload more than one files on codeignitercodeigniter multiple file upload examplemultiple file upload in php codeignitermultiple upload codeigniter ajaxupload multiple file in codeignitercodeigniter 3 multiple image upload with previewupload file multiple codeigniter 3codeigniter multiple file upload githubcodeigniter 3 multiple file uploadmultiple pdf file upload in codeignitermultiple image upload with codeigniterhow to upload multiple and single both image in codeigniter api2 file upload codeignitermultiple file upload codeigniter demohow to upload two files on same form different path in codeignitermultiple file upload in codeigniter 4multiple file upload codeignitermultiple file upload in codeigniter step by step 24this upload do upload in codeigniter multi fileformdata codeigniter multiple filescodeigniter 4 multipart file upload formupload multiple files in codeigniterphp multiple image upload codeignitermultiple file file upload in codeignitermultiple file upload atr in codeigniterupload and show multiple images in codeignitercodeigniter upload multipart file uploadsave multiple file codeigniter 3upload multiple image in codeignitertwo different field image upload to different location in codeigniterhow to upload two files on same form different path in codeigniter