uploading file not working in codeigniter 3 error: you did not select any file

uploading file not working in codeigniter 3 error: you did not select any file

Content Index :

uploading file not working in codeigniter 3 error: you did not select any file
Tag : php , By : Bas
Date : November 26 2020, 03:01 PM

I hope this helps you . well after a lot of research and trying lots of codes and i solved my issue here's the full thing the controller code:
 public function create($id)
        $config ['upload_path'] = 'uploads';
        $config ['allowed_types'] = 'gif|jpg|png';
        $config ['encrypt_name'] = TRUE;

        $package = Package::find($id);

        $files = $_FILES;
        $cpt = count($_FILES ['images'] ['name']);

        for ($i = 0; $i < $cpt; $i++) {

            $_FILES ['images'] ['name'] = $files ['images'] ['name'] [$i];
            $_FILES ['images'] ['type'] = $files ['images'] ['type'] [$i];
            $_FILES ['images'] ['tmp_name'] = $files ['images'] ['tmp_name'] [$i];
            $_FILES ['images'] ['error'] = $files ['images'] ['error'] [$i];
            $_FILES ['images'] ['size'] = $files ['images'] ['size'] [$i];
            if ($this->upload->do_upload('images')){
                $upload_data = $this->upload->data();
                $file_name = $upload_data['file_name'];
                $package->create_images(array('image_location' => $file_name));

<div class="container">
    <?= form_open_multipart('admin/images/create/' . $this->uri->segment(4)) ?>
    <div class="row">
        <div class="col-md-8 publish">
            <h4>Image Gallery</h4>
            <div class="line"></div>
                <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>

                    <div class="input-group control-group after-add-image">

                        <label><input type="file" name="images[]"></label>

                        <div class="input-group-btn">
                            <button class="btn btn-success add-image" type="button"><i class="glyphicon glyphicon-plus"></i> Add</button>


                <div class="line"></div>

            <?= form_submit('', 'Submit', 'class="publish-btn"') ?>

            <?= form_close()?>
            <div class="clear-all"></div>
            <!-- Copy Fields-These are the fields which we get through jquery and then add after the above input,-->
            <div class="copy-field" style="display: none">
                <div class="control-group input-group" style="margin-top:10px">
                    <label><label><input type="file" name="images[]"></label></label>
                    <div class="input-group-btn">
                        <button class="btn btn-danger delete" type="button"><i class="glyphicon glyphicon-delete"></i> Remove</button>
            <script type="text/javascript">
                $(document).ready(function() {

                    //here first get the contents of the div with name class copy-fields and add it to after "after-add-more" div class.
                        var html = $(".copy-field").html();
//here it will remove the current value of the remove button which has been pressed


No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Uploading zip and rar file not working in codeigniter

Tag : php , By : UpperLuck
Date : March 29 2020, 07:55 AM
this will help setting i have created for allowed type: , i replace the mime.php configuration for zip and rar to:
 'zip'  =>  array('application/x-zip', 'application/zip', 'application/x-zip-compressed','application/force-download','application/octet-stream'),
 'rar'  =>  array('application/x-rar', 'application/rar','application/x-rar-compressed','application/force-download','application/octet-stream'),

File uploading is not working properly in codeigniter

Tag : php , By : Chris Woods
Date : March 29 2020, 07:55 AM
may help you . I am using code-igniter to upload files with two input boxes . But my code not uploading both the files i m getting same file two times. , Please change your PHP code and try this out

Error on uploading CSV File in Codeigniter

Tag : php , By : liquidx
Date : March 29 2020, 07:55 AM
may help you . Instead of changing the mime type you can go with the CALLBACK function This will add more portability too...
 function importcsv() {

        $data['addressbook'] = $this->csv_model->get_addressbook();
        $data['error'] = '';    //initialize image upload error array to empty

    $this->form_validation->set_rules('uploaded_file','Uploaded file', 'trim|callback_chk_attachment');

        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = '*';
        $config['max_size'] = '1000';

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

        // If upload failed, display error
        if (!$this->upload->do_upload()) {
            $data['error'] = $this->upload->display_errors();

            $this->load->view('csvindex', $data);
        } else {
            $file_data = $this->upload->data();
            $file_path =  './uploads/'.$file_data['file_name'];

            if ($this->csvimport->get_array($file_path)) {
                $csv_array = $this->csvimport->get_array($file_path);
                foreach ($csv_array as $row) {
                    $insert_data = array(
                $this->session->set_flashdata('success', 'Csv Data Imported Succesfully');
                //echo "<pre>"; print_r($insert_data);
            } else 
                $data['error'] = "Error occured";
                $this->load->view('csvindex', $data);


Call Back function for File Upload validation:

        public function chk_attachment() // callback validation for check the attachment extension
            $file_type = array('.csv');
                $ext = strtolower(strrchr($_FILES['uploaded_file']['name'],"."));
                    return true;
                    $this->form_validation->set_message('chk_attachment','Attachment allowed only csv');
                    return false;
               $this->form_validation->set_message('chk_attachment','image field is required');
                    return false;

File uploading error in Codeigniter

Tag : php , By : Robin Buitenhuis
Date : March 29 2020, 07:55 AM
hop of those help? I am trying to upload an image in codeigniter. , Refer this code. this will surely work for you
public function uploadImage() {
        $this->load->helper(array('form', 'url'));  
        $config['upload_path'] = 'assets/images/b2bcategory';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '1000';
        $config['max_width'] = '2024';
        $config['max_height'] = '1768';
        $config['width'] = 75;
        $config['height'] = 50;
        if (isset($_FILES['catimage']['name'])) {
            $filename = "-" . $_FILES['catimage']['name'];
            $config['file_name'] = substr(md5(time()), 0, 28) . $filename;
        $config['overwrite'] = TRUE;
        $config['remove_spaces'] = TRUE;
        $field_name = "catimage";
        $this->load->library('upload', $config);
        if ($this->input->post('selsub')) {
            if (!$this->upload->do_upload('catimage')) {
                //no file uploaded or failed upload
                $error = array('error' => $this->upload->display_errors());
            } else {
                $dat = array('upload_data' => $this->upload->data());
                $this->resize($dat['upload_data']['full_path'],           $dat['upload_data']['file_name']);
            $ip = $_SERVER['REMOTE_ADDR'];
            if (empty($dat['upload_data']['file_name'])) {
                $catimage = '';
            } else {
                $catimage = $dat['upload_data']['file_name'];
            $data = array(            
                'ctg_image' => $catimage,
                'ctg_dated' => time()


Error in codeigniter while file uploading

Tag : codeigniter , By : Al Dimond
Date : March 29 2020, 07:55 AM
To fix the issue you can do Are you using this code for multiple image upload? If you are using for multiple image then please load upload library $this->load->library('upload') outside loop.
Please provide full code with method name if not multiple images.
Related Posts Related QUESTIONS :
  • How to extract integer and decimal numbers in PHP string correctly?
  • Parsing Sub-Object from an XML Feed with objects
  • Getting error "Unknown column 'text' in 'field list'"
  • How to properly get onedrive access token via php and curl
  • How to add spell check to a php function
  • Is it posible to create css rules with php?
  • Pretty URL with $_GET method
  • Wordpress always load same page - index.php
  • Find value in array and return with new from different array
  • PHP multiple file upload with different keys
  • Can't modify times one a time without weird errors
  • Get size of scraped image with domcrawler (Goutte)
  • Laravel - Ordering a collection of models
  • PHP Fatal error: Uncaught Error: Call to a member function setFetchMode() on boolean
  • Strict Standards: Only variables should be passed by reference in /main_dir/sub_dir/backup.php
  • Uncaught Google_Exception: (update) unknown parameter: 'copyRequiresWriterPermission'
  • Laravel 5 form does not redirect with old input
  • How to get values greater than or equal to in Mysql database sql when its a value like 1:00 PM?
  • PHP datediff overday issue
  • Masking an auto incrementing primary key
  • How to grab a String BEFORE a certain word
  • ZF2 Routing Multiple Controllers based on route constraints
  • How to deregister/dequeue jquery.sticky.js in Elementor (Pro)?
  • How to fix errors counting words in text plain with PHP?
  • How to get View data in Laravel in custom helper or directive
  • Creating a new data entry into a database with eloquent and trying to access the variable in the url
  • How to test authentication using Laravel Dusk?
  • PHP parse_str not getting all $_GET variables
  • Variable issues in php class
  • Get orders between dates in Codeigniter
  • Eloquent Special Chars Issue
  • Keeping leading zeros column Mysql
  • Current level navigation in Wordpress
  • Add a custom text to WooCommerce cart items if the product has a specific shipping class
  • Error connecting to CommissionJunction Token : [60] SSL certificate problem: unable to get local issuer certificate
  • How do I add a new key value pair to an object in PHP?
  • Http post request to php with dart
  • How to add a route in with blade into parameters of a component
  • How can i get the source of a 777 - CHMOD php file?
  • Convert 2010-04-16 16:30:00 to "Tomorrow Afternoon"
  • How can I hide a $_GET variable to be more secured in PHP?
  • Login to Gmail Inbox using Curl?
  • Upload Excel or CSV file to MySQL with PHP
  • Outlook Marking Email as Junk Email
  • Upload an image using class.upload.php via AJAX, display image in form using jQuery
  • mysql_connect() causes page to not display (WAMP)
  • How to limit a users uploaded image size using PHP
  • What's the difference whether or not to run PHP in safe mode?
  • Logging in to a website cURL
  • Using php to create a password system with chinese characters
  • PHP is not called properly in IE using set interval function in Javascript
  • How to read pdf, ppt, xl, doc files content into a string in php/python
  • php script for currency conversion
  • In PHP... best way to turn string representation of a folder structure into nested array
  • PayPal for Indian Rupees (INR) any solution
  • PHP Deployment to Live Server
  • Ideal Multi-Developer Lamp Stack?
  • How can I save an image from a file input field using PHP & MySQL?
  • Warning: array_multisort() [function.array-multisort]: Argument #1 is expected to be an array or a sort flag in
  • Connecting to external MySQL DB from a web server not running MySQL
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com