Welcome Guest, Not a member yet? Register   Sign In
thumnail creating problem
#1

[eluser]mrcoder[/eluser]
Hi,

I am new to CI.the view contains 4 uploads and i am uploading 4 images through an array and iam itterating.after that iam creating the thumbnail in the loop.the thumbnail is creating for the first image only.

MY CODE IS

$config['upload_path'] = 'assets/uploads';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
$file_name_arr = array('photo1', 'photo2', 'photo3', 'photo4');


for ($i = 0; $i < 4; $i++) {
if ($_FILES[$file_name_arr[$i]]['name'] != '') {

$id = $this->input->xss_clean($this->input->post("h".$file_name_arr[$i]));
if (!$this->upload->do_upload($file_name_arr[$i])) {
$error = array('error'=>$this->upload->display_errors());

} else {

$data1 = array('upload_data'=>$this->upload->data());
//$this->load->view('upload_success', $data);
$filename = $data1['upload_data']['file_name'];

if ($filename == '') {
$target1 = '../../assets/uploads/nopicture.jpg';
//echo $this->_create_thumbnail($filename);
} else {

$config['image_library'] = 'gd2';
$config['source_image'] = 'assets/uploads/'.$filename;

$config['new_image'] = 'assets/thumbnail/'.$filename;
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 132;
$config['height'] = 97;
print_r($config);
$this->load->library('image_lib', $config);
if (!$this->image_lib->resize()) {
echo $this->image_lib->display_errors();
}
$target1 = '../../assets/uploads/'.$filename;
/* $this->_create_thumbnail($filename);
$data['uploadInfo'] = $filename;
$data['thumbnail_name'] = 'thumb'.$filename;
print_r( $data['thumbnail_name'] );*/



}
#2

[eluser]Clooner[/eluser]
What is the problem? What happens or doesn't?
#3

[eluser]mrcoder[/eluser]
i have to create thumbnail for all the 4 images but its creating only one thumbnail.the thumbnail is created only for the first image in the array.
#4

[eluser]Clooner[/eluser]
Your code is very very messy so I won't dive into that. But probably you have to set
Code:
$config['thumb_marker'] = "thumb_".$i;
#5

[eluser]Clooner[/eluser]
Or it could be by how you access your upload data




Theme © iAndrew 2016 - Forum software by © MyBB