upload multiple files in codeigniter

Solutions on MaxInterview for upload multiple files in codeigniter by the best coders in the world

showing results for - "upload multiple files in codeigniter"
Fátima
18 Mar 2020
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       }
Josefa
19 Aug 2018
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
Emil
09 Apr 2018
1views
2---------
3
4<?php echo validation_errors();?>
5<?php echo form_open_multipart('pages/multiple_files');?>
6<p><input type="file" multiple="multiple" name="image_name[]" class="form-control" /></p>
7
8<input type="submit" class="btn btn-success btn-block"/> 
9</form>
10
11Controller
12----------
13
14public function multiple_files(){
15  $this->load->library('upload');
16  $image = array();
17  $ImageCount = count($_FILES['image_name']['name']);
18        for($i = 0; $i < $ImageCount; $i++){
19            $_FILES['file']['name']       = $_FILES['image_name']['name'][$i];
20            $_FILES['file']['type']       = $_FILES['image_name']['type'][$i];
21            $_FILES['file']['tmp_name']   = $_FILES['image_name']['tmp_name'][$i];
22            $_FILES['file']['error']      = $_FILES['image_name']['error'][$i];
23            $_FILES['file']['size']       = $_FILES['image_name']['size'][$i];
24
25            // File upload configuration
26            $uploadPath = './assets/images/profiles/';
27            $config['upload_path'] = $uploadPath;
28            $config['allowed_types'] = 'jpg|jpeg|png|gif';
29
30            // Load and initialize upload library
31            $this->load->library('upload', $config);
32            $this->upload->initialize($config);
33
34            // Upload file to server
35            if($this->upload->do_upload('file')){
36                // Uploaded file data
37                $imageData = $this->upload->data();
38                 $uploadImgData[$i]['image_name'] = $imageData['file_name'];
39
40            }
41        }
42         if(!empty($uploadImgData)){
43            // Insert files data into the database
44            $this->pages_model->multiple_images($uploadImgData);              
45        }
46  }
47  
48Model
49---------
50  public function multiple_images($image = array()){
51
52     return $this->db->insert_batch('profile_images',$image);
53             }
54
55
queries leading to this page
multiple file file upload in codeignitermultiple image upload in codeigniter with databasecode igniter upload multiple imagesmultiple upload codeigniter ajaxupload multiple files php codeigniterfile upload in codeigniterupload image in codeigniter 4images upload and edit in codeigniterupload multiple file codeigniter 3how to upload multiple image in codeigniter apihow to insert mutiple file in database in codignitermultiple file upload in codeigniter 4codeigniter upload multiple image rest apimultiple image upload commana seprated in codeignitermultiple file upload in codeigniter step by stepcodeigniter 3 upload multiple files in for loop 5bmultiple image upload in php codeigniterhow to insert multiple image in database using codeignitercodeigniter multiple file upload examplecodeigniter how to send multiple image files array in controllerhow to upload multiple files rest api in codeigniter and store in databasemultiple image upload in codeigniterhow to upload image with multiple path in codeigniterhtml for multiple file upload in codeignitermultiple file upload in codeigniter 3upload multi image in codeigniterhandle multiple images upload in cicodeigniter 3 image upload with previewcodeigniter 3 multiple image upload with previewcodeigniter 3 multiple file upload 28array 29two different field image upload to different location in codeignitermultiple image upload to server in codeignitercodeigniter 4 multipart file upload formupload multiple images in codeigniter with previewupload multiple file filepond codeigniter 3multiple image upload with thumbnail php codeignitercodeigniter 3 upload multiple filescodeigniter upload multipart filemultiple file upload codeigniterformdata codeigniter multiple filesupload multiple image codeignitermulti image upload sql codeignitercodeigniter multiple file upload easyupload multiple images in codeigniterupload multiple image input form php codeignitercodeigniter attach multiple filescodeigniter multiple file upload 24this 3eload 3elibrary 28 27upload 27 2c 24config 2c multilpe uploadhow to upload two images into two fields using codeignitermultiple file file upload in codeigniter live democodeigniter multiple uplozdupload 2 file at a time using different location codeigniteradd multiple images in codeigniter 4upload 2 input codeigniterhow to upload multiple images in php codeigniterhow to insert multiple image file in codeignitermultiple image upload in codeigniter 3 using ajaxupload multiple image php codeigniter 24this upload do upload in codeigniter multi fileupload multiple images in different different folder in codeignitermultiple file upload on codeignitercodeigniter 3 single file uploadmultiple file upload with codeigniter 3multiple file uploadafter login codeignitermultiple file upload in codeigniter using databasesave multiple file codeigniter 3upload multiple images and save to database ajax codeigniter 3codeigniter two image uploadmultiple image upload in codeigniter with database democodeigniter multiple image upload with previewhow to upload multiple image in codeignitermultiple file attach in codeigniter live demomultiple files upload in codeigniterupload multiple image in codeigniter webslessonupload two images in codeigniter2 file upload in codeignitermultiple files download ajax codeignitercodeigniter jquery upload multiple image and previewpreview multiple image before upload in codeigniter 3how to insert multi image file field in codeigniterupload multiple images in codeigniter using ajaxmultiple image upload with codeignitermultiple image update in codeigniterhow to update multiple images in codeigniterupload file in codeigniterupload files from 2 filefield codeigniterhow to get multiple file upload value in codeignitermultiple image upload in codeigniter 3how to add multiple image in codeigniterupload multiple file codeigniter 3 with upload libraryupload more than one file codeigniterhow to upload two different files in codeignitermultiple upload file codeigniter 3multiple upload file codeigniterupload multiple images in different folder in codeigniterhow to upload two files on same form different path in codeignitermultiple file upload in codeigniter using ajaxcodeigniter multiple file upload 28array 29how i can upload more than one file in codeigniter 3upload multiple foto and file codeignitercodeigniter multi file uploadmulti image upload code cihow to save multiple image in database in codeigniterupload 2 file in different directory codeignitercodeigniter handling multiple file uploadupload multiple images codeigniterupload file dengan ajax codeigniterhow to upload two images in codeingiter with different inputhow to upload multiple file in codeigniteruploading multipleimages with codeignitercodeigniter two upload in controller different types configupload more than one files on codeignitermultiple image upload in codeigniter web servicemultiple file upload in cicodeigniter mulstiple file uploadmultiple file upload in codeignitermultiple image upload codeigniterupload 2 file with two different config in codeigniterupload multiple file in codeigniter with add more optionupload multiple files in codeigniter2 file upload chhsee in codeignitermultiple images upload in codeigniter using databasedownload multiple files ajax codeigniterhow to update multiple image in codeigniterupload multiple files on codeigniterandroid studio upload multiple images to server codeigniter 3codeigniter do multi uploadupload files from multiple field codeignitermultiple pdf file upload in codeigniterhow to upload array of image in codeignitermultiple image view in codeigniter with databasemultiple images upload in cicurd multiple image upload in codeignitercodeigniter 3 multiple file upload 28array 29 githubupload file codeignitermulti image upload in codeignitermulti upload codeignitermulti upload file codeigniterupload multiple image in codeigniter 4codeigniter multiple file upload githubadd multi photo using codeignitermultiple image upload in codeigniter with database source codemultiple file upload in api codeignitercodeigniter 4 multiple file uploadmultiple file uploading in codeignitercodeigniter upload multi file with different namecodeigniter upload multipart file uploadi am upload multiple file but same file upload multiple time in codeigniterupload multiple file in different folder location in codeignitercodeigniter file upload multiple filesadding multiple images in codeigniter not saving imageshow to upload multiple images in codeigniter 4upload library in codeigniter use for multiple timescodeigniter file upload with file full path database saverest api upload multiple images using codeigniterci multiple image uploadcodeigniter 3 multiple file uploadupload multiple file in codeignitermultiple file upload atr in codeigniterhow to upload multiple images in codeignitermultiple image upload in codeigniter step by stepsame image upload path to database codeignitercodeigniter upload multiple file type2 file field in codeigniterupload multiple image files in codeigniterhow can i create multiple config array for file upload in codeignitercodeigniter 4 multiple image uploadset upload path to two different folders in codeignitermultiple image upload code in codeigniterupload multiple image in codeigniter weblessoncodeigniter multiple image upload and resizecodeigniter multiple image uploadmultiple file attach in codeignitermultiple file upload in php codeignitercodeigniter upload multiple imagesmultiple file upload codeigniter demohow to upload multiple and single both image in codeigniter apimultiple file upload in codeigniter crud functionmulti file upload in codeignitermultiple image upload using ajax in codeigniterhow to upload multiple images with data in codeigniterupload multiple input image php codeigniterupload and show multiple images in codeignitercodeigniter 3 php upload multiple filesmultiple image insert in codeigniterhow to upload multiple files in codeignitercodeigniter multiple uploadfilepond multiple file upload codeigniter 3handle two upload fields in a single form codeigniterhow to upload multiple files in codeignitersame upload path in database codeigniterhow to uplaod multiple files in codeignitersingle image upload in codeignitermultiple file upload codeigniter 3multiple files upload codeigniter ajax2 file upload codeigniterform with image upload in codeigniter in multiple ajaxupload multiple photo codeigniter 3 jqueryadd multiple images in codeigniterupload file multiple codeigniter 3upload multiple files in php codeigniter input file multipleupload multiple codeigniter 3upload multiple image in codeignitercodeigniter upload single imageupload two files in codeignitercodeigniter upload multiple filesscript multiple file upload code codeigniter 4code for uploading multiple image 2fvideo in codeigniter using for loopupload multiple file codeignitermultiple image upload in codeigniter with json farmart database demohow to get multiple files in postman codeigniterdo upload codeigniter multipleupload multiple files in codeigniter