-1
$config['file_name'] = $logged_in_user['user_name'].".png";
                    $config['upload_path'] = 'assets/profiles/';
                    $config['allowed_types'] = 'gif|jpg|png';
                    $config['overwrite'] = true;

                    $this->load->library('upload', $config);
                    if ($this->upload->do_upload("picture")) {

                        print_r($this->upload->data());
                        $upload_data = $this->upload->data();

}

When i am running this function i have already a file abc.png in my directory. As the upload methods runs, it is saving a file with abc_.png Why it is appending underscore? I read in other post here that this could be because of spaces. But i dont think there is any space in $config['file_name'] = $logged_in_user['user_name'].".png";

Please note that the already existed abc.png is pure PNG image while the file i am uploading is actually a jpeg image which i concatenate with .png just to make the file name same. I will do image conversion later after fixing this issue.

Thanks

Raheel
  • 8,716
  • 9
  • 60
  • 102

1 Answers1

0

Try doing this to make sure there are no spaces:

Change

$config['file_name'] = $logged_in_user['user_name'].".png";

To

$config['file_name'] = trim($logged_in_user['user_name']).".png";
Hans
  • 3,403
  • 3
  • 28
  • 33
  • i have double checked it with file exists function check. It displaying that file already exists this means that it should be replaced – Raheel Mar 28 '14 at 13:46
  • Maybe it's this? http://stackoverflow.com/questions/5728059/changing-name-of-the-uploaded-file-in-codeigniter-dots-underscores – Hans Mar 28 '14 at 13:57