CodeIgniter Forums
Upload multiple files to different locations from one form - 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: Upload multiple files to different locations from one form (/thread-5419.html)



Upload multiple files to different locations from one form - El Forum - 01-21-2008

[eluser]phpzone[/eluser]
hi

i'm working on an admin system at the moment and as part of one form i need to upload both and image and a document, so i need two $_FILES entries on the one form, the files when uploaded need to be saved into different paths so i need the chance to change $config['upload_path'] parameter for the uploader.

can the default CI uploader do this? it seems to default to looking for an input called 'userfile' if i recall from the last time i used it.

any advice gratefully received, otherwise i'll just have to "roll-my-own" function.

many thanks in advance.


Upload multiple files to different locations from one form - El Forum - 01-21-2008

[eluser]Michael Wales[/eluser]
Upload them both to a central location, then move them to their final location. Your probably going to have to drop down into PHP for the moving - which isn't difficult at all.


Upload multiple files to different locations from one form - El Forum - 07-11-2008

[eluser]Unknown[/eluser]
I have a similar situation, but other issues:

1. I want to display the error messages individual, above each upload input field. At this moment all error messages can be found by calling $this->upload->display_errors() (for multiple fields the messages are grouped).

2. Is there a native CI way to validate an upload field without moving the file to the final location? At this moment if I have a form with multiple fields and the form fails on validation except the upload field (which is being validate separately), the image will be uploaded on the server, but the form is not processed. I made a workaround for this by adding a new parameter to do_upload() function from Upload class, but I'm wondering if there is any other way to do this.

Thanks!

LE: #1 has been solved by reinitializing the class after validating the 1st upload field