Welcome Guest, Not a member yet? Register   Sign In
upload class.. need two upload_paths
#1

[eluser]generalsalt[/eluser]
Have a two fields to upload files. In my controller I have:

Code:
$config['upload_path'] = './pics';


This field send images to the 'pics' folder.

Right below this field I have another, I'd (ideally) like to have CI send this to a folder called 'thumbnails'.

Code:
$config['upload_path'] = './thumbnails';

My question is, how do you specify–per field, what upload path to take? Everything is now is going to 'pics'.
#2

[eluser]Mike Ryan[/eluser]
You can specify the path when you load or initialise the class. Try this:
Code:
//upload class has already been loaded, with $config['upload_path'] = './pics';

//do the first upload (pics)
...

//re-initialise the upload class with the new path
$config['upload_path'] = './thumbnails';
$this->upload->initialize($config);

//do the second upload (thumbnails)
...

I haven't actually tested to see it the initialize function can be run twice. If it doesn't work, unload the Upload library and load it again with the new path.

Code:
unset($this->upload);
#3

[eluser]Aken[/eluser]
The initialize() function can be ran as many times as you need to, all it does is change variables. Just keep in mind that initialize() will reset back to defaults, and only change the variables you specify in the $config array. So make sure to reuse your original $config array and only change what's necessary between the two.
#4

[eluser]mamen[/eluser]
sorry if i ask can u spesifik file

i try to make folder in root document file
but not work

this my folder

folder root -> myCI -> upload ->images
-> system -> application


can u tell me where is path




Theme © iAndrew 2016 - Forum software by © MyBB