Welcome Guest, Not a member yet? Register   Sign In
uploaded file is being appeded with an underscore even after overwrite is set to true.
#1

[eluser]Unknown[/eluser]
Code:
$config['file_name'] = $logged_in_user['user_name'].".png";
                    $config['upload_path'] = 'assets/profiles/';
                    $config['allowed_types'] = 'gif|jpg|png';
                    $config['remove_spaces'] = false;
                    $config['overwrite'] = true;

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

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

The goal is to change display picture of user. As user upload the file it should replace his existing picture with the new one.
The existing picture is hardcoded as username.png as it is a default image when user creates account.

Now by the above code. when it runs , it uploads the new file not by replacing the existing file instead it is making file name like username_.png .

I want the existing file to be replaced with new.

Kindly help

Thanks
#2

[eluser]InsiteFX[/eluser]
Try doing a var_dump($upload_data); and see what you are getting back.
#3

[eluser]Unknown[/eluser]
Code:
array(14) { ["file_name"]=> string(16) "raheel.khan_.png" ["file_type"]=> string(10) "image/jpeg" ["file_path"]=> string(35) "/home/tradeban/erp/assets/profiles/" ["full_path"]=> string(51) "/home/tradeban/erp/assets/profiles/raheel.khan_.png" ["raw_name"]=> string(12) "raheel.khan_" ["orig_name"]=> string(16) "raheel.khan_.png" ["client_name"]=> string(6) "me.jpg" ["file_ext"]=> string(4) ".png" ["file_size"]=> float(58.16) ["is_image"]=> bool(true) ["image_width"]=> int(586) ["image_height"]=> int(546) ["image_type"]=> string(4) "jpeg" ["image_size_str"]=> string(24) "width="586" height="546"" }




Theme © iAndrew 2016 - Forum software by © MyBB