Renaming file in upload - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Renaming file in upload (/showthread.php?tid=51396) |
Renaming file in upload - El Forum - 05-02-2012 [eluser]Unknown[/eluser] Hello, I stuck in renaming file. What I have to do is: $config['file_name'] = "file name" . "some word"; "file name" represents the actual name of the file How can I get both names in one string that will be the new full name of the file in folder. Renaming file in upload - El Forum - 05-02-2012 [eluser]ojcarga[/eluser] I am not sure if that is possible, cause the $config[] array must be set before the do_upload() method. So in that point, we don't have the file information yet, I guess that is the workflow. I see two ways: 1) After the do_upload() method and if it succeed use the helper http://ellislab.com/codeigniter/user-guide/helpers/file_helper.html to manage the new file, knowing that we have the information related to it with this method $this->upload->data() 2) Easier is to have a hidden input in the view and catch the filename of the file the user selected with Javascript, and then in the controller before setting and loading the library - $this->load->library('upload', $config); - we can have the filename and add it to $config[] array. |