Welcome Guest, Not a member yet? Register   Sign In
How to separate the directory for image and image thumbnail when the image is uploaded ?
#1

[eluser]dimasVS[/eluser]
Hi All,
I need your help,
I want to separate the directory when the image is uploaded, I want to put "image" in "uploads" directory and "image_thumb" in "upload_thumb" directory..

This is my script :

Code:
function do_upload(){
        $n = rand(0,100000);
        $nama_file   = $_FILES['userfile']['name'];
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '100';
        $config['max_width'] = '1024';
        $config['max_height'] = '768';
        $config['encrypt_name'] = "$n";
        $this->load->library('upload', $config);
        if ( ! $this->upload->do_upload())
            {
                $error = array('error' => $this->upload->display_errors());
            
        $this->load->view('admin/employeeAdd', $error);
        }    
    else
        {
        $data = array('upload_data' => $this->upload->data());
                $image_data = $this->upload->data();
                $file_name = $image_data['file_name'];
                $this->Model_admin->imageUpload($file_name);
                
                $config['image_library'] = "gd2";
                $config['source_image'] = "./uploads/$file_name";
                $config['create_thumb'] = TRUE;
                $config['maintain_ration'] = TRUE;
                $config['width'] = 50;
                $config['height'] = 50;
                // in here I put the second of $config['upload_path']
                $this->load->library('image_lib', $config);
                $this->image_lib->resize();
                
        echo "Register Successfull<br />";
                echo anchor('admin/employee', 'Back');
        }
    }

how to change the path ?
I've been trying by put $config['upload_path'] after image uploaded but always failed..
Thanks for your help !
#2

[eluser]Joey Beltran[/eluser]
I tried this $config['new_image'] = '/path/to/new_image.jpg'; instead of using $config[‘upload_path’] and it worked. That will create a copy as thumbnail since you are resizing the file.

Checkout the notes for "Creating a Copy" at Image Manipulation Class docs.

For easy access to CI documentation, I suggest this -> http://www.kintek.com.au/web-design-blog...extension/
#3

[eluser]dimasVS[/eluser]
Hi Joey,
Thanks for your answer..

But I also want to upload the origin image, not only thumbnail.
Any suggest ???




Theme © iAndrew 2016 - Forum software by © MyBB