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]hqhdn[/eluser]
You can to try with $this->image_lib->clear() ( The clear function resets all of the values used when processing an image. You will want to call this if you are processing images in a loop.)

Or you can go to
Code:
http://ellislab.com/forums/viewthread/109434/
to know how can you use "class.upload.php by Colin Verot" in CI.
#3

[eluser]dimasVS[/eluser]
thanks hqhdn,
It just cause of directory permission...
I've been repair it by chmod.. Smile




Theme © iAndrew 2016 - Forum software by © MyBB