[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 />
<input type="submit" value="upload" />
</form>
</body>
</html>