Welcome Guest, Not a member yet? Register   Sign In
multiple file uploads with thumb creation
#1

[eluser]e-nigma[/eluser]
Hi everyone,

does anyone here on CI forum have multi file uploads working for single file element in view and can create thumbnails for multi file uploads???? If so could you please help???

I have multiple file uploads working just fine but only one thumbnail is getting created for the last file uploaded and only the last file.
I know there's bugs with Clear() and possibly initialize and I already corrected the ones with Clear() and I am still getting not any difference in output.
I understand inevitability of bugs but this is absolutely ridiculous. Can someone please help!!!
I can share my multi upload library file and multi_image_lib via email but I can't fit into post.
However my controller and view is as follows below but most of the code is in the two libraries I'm using. Wondering if anyone extended CI_Image_lib for multi file uploads?
Code:
//CONTROLLER//
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class dyng extends CI_Controller {

public function __construct()
{
  parent::__construct();
  $this->load->library(array('table','form_validation'));
  $this->load->helper(array('form', 'url'));
}

private $data = array(
    'dir' => array(
        'original' => './uploads/original/',
        'thumb' => './uploads/thumbs/'
    ),
    'total' => 0,
    'images' => array(),
    'error' => ''
);

public function index()
{
   $this->load->view('dyn_view');
}

public function mimes()
{  
   $this->form_validation->set_rules('userfile','userfile','trim|xss_clean');
   $this->form_validation->set_rules('btn_upload','btn_upload','trim|xss_clean');

    if ($this->input->post('userfile')) {
        
   $this->go_upload();
   $this->index();
    }

    else {

$error = array('error' => $this->upload->display_errors());
$this->index();

}

//exit

}

public function do_upload()
{

$this->load->library('upload');
$this->load->library('multi_upload');

        $c_upload = array(
        'upload_path'    => $this->data['dir']['original'],
        'allowed_types'  => 'gif|jpg|png|jpeg|x-png',
        'max_size'       => '3500',
        'max_width'      => '3600',
        'max_height'     => '1200',
        'remove_spaces'  => TRUE
   );

        $files = $this->multi_upload->go_upload();
        
        if (!$files)        
        {
            $error = array('error' => $this->upload->display_errors());
            $this->index();
        }    

   else

   {

    $data = array('upload_data' => $files);  

       $this->multi_mime_handle();
       $this->index();
        }
  
$this->multi_upload->mt_initialize($c_upload);
  
//exit

}
  
private function multi_mime_handle()
{
$this->load->library('image_lib');
$this->load->library('multi_image_lib');

$imgs = $this->multi_upload->get_data();

        // create thumbnails
        $new_images = $this->data['dir']['thumb'].$imgs['file_name'];

        $c_img_lib = array(
            'image_library'     => 'gd2',
            'source_images'      => $imgs['full_path'],
            'create_thumb'      => TRUE,
            'thumb_marker'      => '_thumb',
            'maintain_ratio'    => TRUE,
            'widths'             => 100,
            'heights'            => 100,
            'new_images'         => $new_images
        );
  
   $this->multi_image_lib->m_initialize($c_img_lib);
   $this->image_lib->m_resize();

   $this->image_lib->m_clear($c_img_lib);

  //exit

}    

  //ct_exit

}
Code:
//VIEW//
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?>
<html>
<head>
<title>Multi Upload Form</title>
[removed][removed]
[removed][removed]
</head>
<body>
<?php echo form_open_multipart('dyng/do_upload');?>
<input type="file" name="userfile[]" id="userfile" size="20" class="multi" />
<br /><br />
&lt;input type="submit" value="upload" /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
#2

[eluser]GrahamDj28[/eluser]
Hi,

Maybe I can help you.

First of all, when uploading multiple files at once, each file will be posted as a single request. So there is no difference between uploading 1 file or 10 files.

In my CMS I use uploadify, and every file is a single request being posted to a controller for processing. So the Lib for making the thumbs only needs to accept 1 file at a time.

Could you re-post your code using the code tags. Makes it easier to read.
#3

[eluser]InsiteFX[/eluser]
Next time please place your code in code tags!
You can see the code tags in RED right on top of the FAST REPLY!
#4

[eluser]e-nigma[/eluser]
[quote author="GrahamDj28" date="1335947028"]Hi,

Maybe I can help you.

First of all, when uploading multiple files at once, each file will be posted as a single request. So there is no difference between uploading 1 file or 10 files.

In my CMS I use uploadify, and every file is a single request being posted to a controller for processing. So the Lib for making the thumbs only needs to accept 1 file at a time.

Could you re-post your code using the code tags. Makes it easier to read.[/quote]

Sorry Graham!!! I can't fit the library in the post. I can send you the source code via email? I noticed you can't attach files anymore to the posts.
#5

[eluser]e-nigma[/eluser]
[quote author="InsiteFX" date="1335947879"]Next time please place your code in code tags!
You can see the code tags in RED right on top of the FAST REPLY!
[/quote]

Sorry Insite!! Yes I will do that!! My apologies again!!!




Theme © iAndrew 2016 - Forum software by © MyBB