Welcome Guest, Not a member yet? Register   Sign In
Getting name of resized image from image library
#1

[eluser]Thorpe Obazee[/eluser]
This is my method for uploading and then resizing. However, I need to get the name of the thumb image. How do I dynamically get the new name of the thumb image? Is there a function to get this in the image library? of course aside from doing the rename() php function.

Code:
function _upload_pics()
    {
        if ($_FILES)
        {
            $config = array(
                'upload_path'   => './uploads/',
                'allowed_types' => 'gif|jpg|png',
                'max_size'      => '100',
                'max_width'     => '400',
                'max_height'    => '400'
            );
            $this->load->library('upload', $config);

            if ( ! $this->upload->do_upload())
            {
                return FALSE;
            }
            else
            {
                $this->file = $this->upload->data();
                $config = array(
                    'image_library'  => 'gd2',
                    'source_image'   => './uploads/'.$this->file['file_name'],
                    'create_thumb'   => TRUE,
                    'maintain_ratio' => TRUE,
                    'width'          => 120,
                    'height'         => 120,
                    'new_image'      => './uploads/thumb/'.$this->file['file_name']
                );
                $this->load->library('image_lib', $config);
                $this->image_lib->resize();
                return TRUE;
            }
        } // if $_FILES
    }// End upload_pics
#2

[eluser]alectrash[/eluser]
whats in here?

Code:
$_FILES['tmp_name']
#3

[eluser]Thorpe Obazee[/eluser]
[quote author="alectrash" date="1224624117"]whats in here?

Code:
$_FILES['tmp_name']
[/quote]

huh?

Maybe I didn't explain it well. I need to get the string of the resized image. This is already after the uploading.
#4

[eluser]Thorpe Obazee[/eluser]
Anyway, I modified my code like this to get it. If anyone has a better way... don't hesitate :p

Code:
function _save_ad($ad_id = FALSE)
    {
        $ad_data = array(
            'title'           => $this->input->post('title'),
            'user_id'         => $this->session->userdata('user_id'),
            'cat_id'          => $this->input->post('cat'),
            'tags'            => $this->input->post('tags'),
            'price'           => $this->input->post('price'),
            'desc'            => $this->input->post('desc'),
            'floor_flat'      => $this->input->post('floor_flat'),
            'building'        => $this->input->post('building'),
            'street_district' => $this->input->post('street_district'),
            'zone'            => $this->input->post('zone'),
            'date_add'        => date("Y-m-d H:m:s")
        );
        if ($_FILES)
        {
            $ad_data['image'] = $this->file['file_name'];
            $ad_data['image_thumb'] = $this->file['raw_name'].'_thumb'.$this->file['file_ext'];
        }
        $this->ads_model->save_ad($ad_data, $ad_id);
        $this->session->set_flashdata('message', $this->lang->line('ad_saved'));
    }




Theme © iAndrew 2016 - Forum software by © MyBB