Welcome Guest, Not a member yet? Register   Sign In
Upload file and Resize image
#1

[eluser]Unknown[/eluser]
Hi,

I try to use the function do_upload.

I have created the following code:

Code:
$config['upload_path'] = './upload/';
$config['allowed_types'] = 'gif|jpg|png|bmp|jpeg';
$config['max_size']  = '0';
$config['max_width']  = '0';
$config['max_height']  = '0';
$this->load->library('upload', $config);

$configThumb['image_library'] = 'gd2';
$configThumb['source_image'] = '';
$configThumb['create_thumb'] = TRUE;
$configThumb['maintain_ratio'] = TRUE;
$configThumb['width'] = 140;
$configThumb['height'] = 210;
$this->load->library('image_lib');

        for($i = 1; $i < 6; $i++)
        {
            if($_FILES['photo'.$i]['error'] == 0)
            {
                $upload = $this->upload->do_upload('photo'.$i);
                if($upload === true)
                {
                    $data_file = $this->upload->data();
                    if($data_file['is_image'] == 1)
                    {
                        $configThumb['source_image'] = $data_file['full_path'];
                        $this->image_lib->initialize($configThumb);
                        $this->image_lib->resize();
                        $this->image_lib->clear();
                    }
                }
            }
        }

This code upload my files in the directory but the name of the images aren't correct. For information, I use this kind of form:
Code:
...
&lt;input type="file" name="photo1" /&gt;
&lt;input type="file" name="photo2" /&gt;
&lt;input type="file" name="photo3"/&gt;
&lt;input type="file" name="photo4" /&gt;
&lt;input type="file" name="photo5" /&gt;
...

For example, I upload the file 0000.jpg and 0001.jpg.

Result in my directory upload: 0000.jpg, 0000.jpg.jpg, 0000.jpg_thumb.jpg, 0000_thumb.jpg.

I don't understand why the file is renaming and how?

The second file use the name of the first with extension...

Thanks in advance for your help.
#2

[eluser]EmmaMadeleine[/eluser]
such a valuable information alex
#3

[eluser]Tominator[/eluser]
Hi,

You may set $configThumb['new_image'] ...

Tom.
#4

[eluser]Unknown[/eluser]
Hi,

thanks you for your help.

I have used the encrypt name.

$config['encrypt_name'] = true;




Theme © iAndrew 2016 - Forum software by © MyBB