CodeIgniter Forums
Specifying an upload destination folder - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Specifying an upload destination folder (/thread-13861.html)



Specifying an upload destination folder - El Forum - 12-09-2008

[eluser]phpserver[/eluser]
I have been trying to make a script that allows me to specify a folder in which to upload my files(choose a destination folder in the view).I have tried all of my tricks and i cannot seem to get it right.Anybody?.


Specifying an upload destination folder - El Forum - 12-09-2008

[eluser]xwero[/eluser]
have you tried the move_uploaded_file function?


Specifying an upload destination folder - El Forum - 12-09-2008

[eluser]LuckyFella73[/eluser]
hi phpserver,

after calling the do_upload function you can
define the upload folder by:
Code:
$config['upload_path'] = './your_upload_folder/';

In your view you can place a dropdown and set the
values regarding to the folder names you want to switch
between (related to your root folder).

Just catch the dropdown value after calling the do_upload
function like this:
Code:
$destination_folder = $this->input->post('name_of_select_tag');
// and add:
$config['upload_path'] = './'.$destination_folder;

That should work at least if you hav only one level. In case
you need more folder levels you could set up an array with
all your possible folder structure destinations like
Code:
$upload_folders = ('uploads/folder1','uploads/folder2','uploads/folder1/images/');
// and so on
and set up the values of your dropdown according to the array indexes.


Specifying an upload destination folder - El Forum - 12-09-2008

[eluser]phpserver[/eluser]
Thanks luckyfella,it works perfectly.