Search
 
SCRIPT & CODE EXAMPLE
 

PHP

upload multiple files in codeigniter

    private function upload_files($path, $title, $files)
    {
        $config = array(
            'upload_path'   => $path,
            'allowed_types' => 'jpg|gif|png',
            'overwrite'     => 1,                       
        );

        $this->load->library('upload', $config);

        $images = array();

        foreach ($files['name'] as $key => $image) {
            $_FILES['images[]']['name']= $files['name'][$key];
            $_FILES['images[]']['type']= $files['type'][$key];
            $_FILES['images[]']['tmp_name']= $files['tmp_name'][$key];
            $_FILES['images[]']['error']= $files['error'][$key];
            $_FILES['images[]']['size']= $files['size'][$key];

            $fileName = $title .'_'. $image;

            $images[] = $fileName;

            $config['file_name'] = $fileName;

            $this->upload->initialize($config);

            if ($this->upload->do_upload('images[]')) {
                $this->upload->data();
            } else {
                return false;
            }
        }

        return $images;
    }
Comment

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

if($this->input->post('Submit')){

//-----------Image File Section Start Here -----------//

 $config['upload_path'] = './uploads/';   // Directory 
$config['allowed_types'] = 'jpg|jpeg|bmp|png';  //type of images allowed
$config['max_size'] = '30720';   //Max Size
$config['encrypt_name'] = TRUE;   // For unique image name at a time

$this->load->library('upload', $config);  //File Uploading library
$this->upload->do_upload('userfile');  // input name which have to upload 
$video_upload=$this->upload->data();   //variable which store the path

//--------------End of Image File  Section------------------------//



//---------Thumbnail Image Upload Section Start Here -----------//

$config2['upload_path'] = './thumb/';   // Directory 
$config2['allowed_types'] = 'jpg|jpeg|bmp|png'; //type of images allowed
$config2['max_size'] = '30720';   //Max Size
$config2['encrypt_name'] = TRUE;   // For unique image name at a time


$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 
$this->upload->do_upload('txt_thumb');  // File Name
$thumbnail_upload=$this->upload->data(); // store the name of the file 

//--------End of Thumbnail Upload Section-----------//



    $date=date("d-m-Y");  // Store current date in variable 

   // Here the database query to insert

    $data = array(
    'parent_id'=> $this->input->post('txt_parent'),
    'cat_id' => $this->input->post('txt_category'),
    'title'=> $this->input->post('txt_title'),
    'status' => $this->input->post('txt_status'),
    'featured' => $thumbnail_upload['file_name'],
    'image' => $video_upload['file_name'],
    'time'=>$date
    );

       $sql_ins= $this->Insimage->insertimage($data);
       if($sql_ins)
       {
           $data['Success'] = "Image has been succesfully inserted!!";
       }
Comment

PREVIOUS NEXT
Code Example
Php :: php quotations within quotations 
Php :: define constructor in trait php 
Php :: post loop 
Php :: search laravel 
Php :: php slice last arrat 
Php :: laravel signed Route custom domain 
Php :: laravel elequent query 
Php :: laravel How to capture output in a file from php artisan test 
Php :: laravel except method 
Php :: Genrate Random number in php 
Php :: Laravel - Query Builder Left join 
Php :: @lang laravel blade 
Php :: how to execute php function on button click 
Php :: laravel tinker hash password 
Php :: all resource routes laravel 8 
Php :: php split string 
Php :: luhn algorithm 
Php :: disable display error 
Php :: Create a table with PHP in html 
Php :: php undefined index meaNING 
Php :: php artisan add row in table 
Php :: EntityManager get repository 
Php :: echo string in php 
Php :: laravel check if api request 
Php :: script inside php 
Php :: php header not working 
Php :: convert php array to javascript json laravel 
Php :: phpmyadmin drop database 
Php :: laravel collection collapse 
Php :: laravel santum 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =