Welcome Guest, Not a member yet? Register   Sign In
Upload multiple files to different locations from one form


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.

[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.

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.


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

Theme © iAndrew 2016 - Forum software by © MyBB