Uploading multiple images in codeigniter?

user5182392

I'm currently building a portfolio site for a client, and I'm having trouble with one small area. I want to be able to upload multiple images (varying number) inline for each portfolio item, and I can't see an obvious way to do it.

My view.php:

<?php echo form_open_multipart('uploadfile/upload');?>

    <fieldset>
        <div class="form-group">
            <div class="row">
                <div class="col-md-12">
                    <label for="filename[]" class="control-label">Select File to Upload</label>
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="row">
                <div class="col-md-12">
                    <input type="file" name="filename" size="20" />
                    <span class="text-danger"><?php if (isset($error)) { echo $error; } ?></span>
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="row">
                <div class="col-md-12">
                    <input type="submit" value="Upload File" class="btn btn-primary"/>
                </div>
            </div>
        </div>
    </fieldset>

    <?php echo form_close(); ?>
    <?php if (isset($success_msg)) { echo $success_msg; } ?>
    </div>

my controller

if ( ! defined('BASEPATH')) exit('No direct script access allowed');
ini_set("display_errors",1);

class Update_profile extends CI_Controller {

     function __construct()
     {
          // Call the Model constructor
          parent::__construct();
          $this->is_login();
          $this->load->helper(array('form', 'url'));
          $this->load->model('Edit_profile'); 

     }


    public  function index() {

    //  $this->load->view('header2');
        $this->load->view('edit_profile');

    }// index function ends

    public function is_login() {

      $is_login=$this->session->userdata('is_login');
      if(!isset($is_login) || $is_login !=true)
      {
        //don't echo the message from controller 
        echo "you don't have permission to access this page <a href=../Homecontroller/index/>Login</a>";
        die();
      }
  } //is_login function ends

  // function to upload images
    function upload()
    {

        $name_array = array();
        $count = count($_FILES['filename']['size']);
        foreach($_FILES as $key=>$value)
        for($s=0; $s<=$count-1; $s++) {
        $_FILES['filename']['name']=$value['name'][$s];
        $_FILES['filename']['type']    = $value['type'][$s];
        $_FILES['filename']['tmp_name'] = $value['tmp_name'][$s];
        $_FILES['filename']['error']       = $value['error'][$s];
        $_FILES['filename']['size']    = $value['size'][$s];  

        //set preferences
        $config['remove_spaces']=TRUE;
    //  $config['encrypt_name'] = TRUE; // for encrypting the name
        $config['upload_path'] = './upload/';
        $config['allowed_types'] = 'jpg|png|gif';
        $config['max_size']    = '10248';

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

        if (!$this->upload->do_upload('filename'))
        {
            // case - failure
            $upload_error = array('error' => $this->upload->display_errors());
            $this->load->view('edit_profile', $upload_error);
        }
        else
        {
            // case - success
            $upload_data = $this->upload->data();
            $name_array[] = $data['file_name'];
            $data['success_msg'] = '<div class="alert alert-success text-center">Your file <strong>' . $upload_data['file_name'] . '</strong> was successfully uploaded!</div>';
            $this->load->view('edit_profile', $data);

        }
    }
    }

    function edit_profile() {
    //echo "some success";

    } //function edit profile ends
}    

code above not working

Jeremy Jackson

This is what I've used for the last year when I've wanted/needed multiple image uploads in codeigniter:

https://github.com/stvnthomas/CodeIgniter-Multi-Upload

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Uploading multiple images in codeigniter?

From Dev

Conflict when uploading images with multiple file field in codeigniter

From Dev

Uploading multiple images with volley?

From Dev

Uploading multiple images with paperclip?

From Dev

Uploading multiple images with Django

From Dev

Django multiple images not uploading

From Dev

Multiple files uploading not working in Codeigniter

From Dev

Multiple files uploading not working in Codeigniter

From Dev

Multiple image uploading error in Codeigniter

From Dev

I am getting empty array, I need array of image while uploading multiple images in Codeigniter

From Dev

Uploading Multiple Images using CarrierWave

From Dev

Multiple images rename & uploading in PHP

From Dev

Multiple images rename & uploading in PHP

From Dev

All images not uploading in multiple images upload

From Dev

Upload multiple images with codeigniter

From Dev

Uploading multiple images from Share Extension

From Dev

Uploading multiple images with other parameters in Swift

From Dev

Django REST: Uploading and serializing multiple images

From Dev

Uploading multiple images to mysql database on Apache server

From Dev

PHP: Uploading multiple images to imgur at once

From Dev

multiple images uploading and converting them to thumbnails in cakephp

From Dev

PHP: Uploading multiple images at the same time

From Dev

Uploading multiple images in webservice using PHP

From Dev

Uploading multiple images using SRWebClient in Swift

From Dev

uploading/downloading multiple images the right way?

From Dev

Rails and carrierwave uploading multiple images fails

From Dev

Codeigniter: Unable to create thumbnail for multiple images

From Dev

How to upload multiple images using codeigniter?

From Dev

filereader result order changing while uploading multiple images in javascript

Related Related

  1. 1

    Uploading multiple images in codeigniter?

  2. 2

    Conflict when uploading images with multiple file field in codeigniter

  3. 3

    Uploading multiple images with volley?

  4. 4

    Uploading multiple images with paperclip?

  5. 5

    Uploading multiple images with Django

  6. 6

    Django multiple images not uploading

  7. 7

    Multiple files uploading not working in Codeigniter

  8. 8

    Multiple files uploading not working in Codeigniter

  9. 9

    Multiple image uploading error in Codeigniter

  10. 10

    I am getting empty array, I need array of image while uploading multiple images in Codeigniter

  11. 11

    Uploading Multiple Images using CarrierWave

  12. 12

    Multiple images rename & uploading in PHP

  13. 13

    Multiple images rename & uploading in PHP

  14. 14

    All images not uploading in multiple images upload

  15. 15

    Upload multiple images with codeigniter

  16. 16

    Uploading multiple images from Share Extension

  17. 17

    Uploading multiple images with other parameters in Swift

  18. 18

    Django REST: Uploading and serializing multiple images

  19. 19

    Uploading multiple images to mysql database on Apache server

  20. 20

    PHP: Uploading multiple images to imgur at once

  21. 21

    multiple images uploading and converting them to thumbnails in cakephp

  22. 22

    PHP: Uploading multiple images at the same time

  23. 23

    Uploading multiple images in webservice using PHP

  24. 24

    Uploading multiple images using SRWebClient in Swift

  25. 25

    uploading/downloading multiple images the right way?

  26. 26

    Rails and carrierwave uploading multiple images fails

  27. 27

    Codeigniter: Unable to create thumbnail for multiple images

  28. 28

    How to upload multiple images using codeigniter?

  29. 29

    filereader result order changing while uploading multiple images in javascript

HotTag

Archive