Welcome Guest, Not a member yet? Register   Sign In
[solved] CI 1.7.x file uploading auto rename - is there a limit?
#1

[eluser]SPeed_FANat1c[/eluser]
Hi,

I have such file uploading code:
Code:
function do_upload()    
    {
        if($this->membership->is_logged_in())
        {
            // Image configuration
            $config['upload_path'] = './uploads/naujienos/';
            $config['allowed_types'] = 'gif|jpg|png';
            $config['overwrite'] = FALSE;
            $config['file_name'] = 'naujiena.jpg';
            
            
            $this->load->library('upload', $config);
            
            
    
            if(!$this->upload->do_upload())
            {
                
                   $error = $this->upload->display_errors();
                echo $error.':err';    //pagal galune .err javasctriptas atskirs kad cia klaida
            }
            else
            {
                            
                $data = $this->upload->data();
                if($data['image_width'] > 700)
                {
                    $this->load->model('Image_model','image');
                    $task = $this->image->image_resize('./uploads/naujienos/'.$data['file_name']);
                    if($task != 'ok')
                    {
                        echo $task.':err';    //pagal galune .err javasctriptas atskirs kad cia klaida
                    }
                    else echo $data['file_name'];
                }
                else echo $data['file_name'];
                
                
                
            }
        }
        else
        {
            echo 'not_admin';
        }
    }


And it used to work ok, but now I get an error - "The file name you submit already exists on the server"

This function auto renamed files to naujiena1.jpg, naujiena2.jpg and so on. Now I checked the server there is already naujiena99.jpg. Is this possible that there is a limit of 100 such files? Or there might be something else wrong?


EDIT:

yeah, I now made a fresh function from the userguide to do that, and after it reaches naujiena 99 it shows the same error. Hmm.
#2

[eluser]Phil Sturgeon[/eluser]
Yeah this limitation is something that has been reported as a bug and will fixed by 2.0.2 hopefully. I've assigned it to myself, so hopfully I can find some time to sort it out!
#3

[eluser]SPeed_FANat1c[/eluser]
I now added the timestamp

Code:
$config['file_name']  = 'naujiena'.time().'.jpg';




Theme © iAndrew 2016 - Forum software by © MyBB