Welcome Guest, Not a member yet? Register   Sign In
making thumb of uploaded image
#1

[eluser]ratna[/eluser]
i want to make the thumb of the uploaded images. Images upload successfully but the relevant thumbs are not being made. the following code shows no error but i don't get the thumb of the uploaded image. plz suggest.


here is the code !!!!!!!

$config[‘upload_path’] = ‘./uploads/’;
$config[‘allowed_types’] = ‘gif|jpg|png’;
$config[‘max_size’] = ‘100’;
$config[‘max_width’] = ‘1024’;
$config[‘max_height’] = ‘700’;

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

if ( ! $this->upload->do_upload())
{
$error = array(‘error’ => $this->upload->display_errors());
$this->load->view(‘imageResizeV’, $error);
}

$config[‘image_library’] = ‘gd2’;
$config[‘source_image’] =‘uploads/photoname.jpg’;
$config[‘create_thumb’] = TRUE;
$config[‘maintain_ratio’] = TRUE;
$config[‘width’] = 75;
$config[‘height’] = 100;

$this->load->library(‘image_lib’, $config);

if(!$this->image_lib->resize())
{
echo $this->image_lib->display_errors();
}
#2

[eluser]Vicente Russo[/eluser]
Hi

The problem might be on

Code:
$config['source_image'] = 'uploads/photoname.jpg';

Try to play with the result from upload data:

Code:
Array
(
    [file_name]    => mypic.jpg
    [file_type]    => image/jpeg
    [file_path]    => /path/to/your/upload/
    [full_path]    => /path/to/your/upload/jpg.jpg
    [raw_name]     => mypic
    [orig_name]    => mypic.jpg
    [file_ext]     => .jpg
    [file_size]    => 22.2
    [is_image]     => 1
    [image_width]  => 800
    [image_height] => 600
    [image_type]   => jpeg
    [image_size_str] => width="800" height="200"
)

Maybe something like that might work:

Code:
if ( ! $this->upload->do_upload()) {
    $error = array('error' => $this->upload->display_errors());
    $this->load->view('imageResizeV', $error);
} else {
    $data = array('upload_data' => $this->upload->data());
}



$config['source_image'] = $data['upload_data']['full_path'];
#3

[eluser]ratna[/eluser]
i have now this code. but still not thumb being made. can this problem is because of the read write property of the folder where image is uploaded? please suggest.

code is as follow:

if($_FILES['userfile']['name']!='')
{
$config['upload_path'] = './uploads1/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);

if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());

$this->load->view('imageResizeV', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());

$configa['image_library'] = 'gd2';
$configa['source_image'] = $data['upload_data']['full_path'];
$configa['create_thumb'] = TRUE;
$configa['maintain_ratio'] = TRUE;
$configa['width'] = 75;
$configa['height'] = 50;

$this->load->library('image_lib', $configa);

$this->image_lib->resize();
}
}




Theme © iAndrew 2016 - Forum software by © MyBB