How do I upload Multiple Files ? |
[eluser]sirwan.me[/eluser]
Hi, I want to let users upload 1 image and 1 zip file. I want to let the image be uploaded to "./uploads/posts" and the zip to "./uploads/files" .. but my below code only allows me to upload 2 images, and not 1 image and 1 zip. When I upload the 2 images, it saves both in ./uploads/posts with both the same name.. except the second file will be the extension twice.. for example.. Quote:post_username_2342342342.jpg.jpg Below is the controller code: Code: //getting the username of the logged in user, to later add the username on the file name
[eluser]falkencreative[/eluser]
You need to call do_upload() twice, once for each file you are uploading. (and obviously make sure that both uploads are valid). Keep in mind that do_upload() defaults to use the input named 'userfile', so you'll need to pass in the name of the input: Code: $this->upload->do_upload($your_input_name) http://ellislab.com/codeigniter/user-gui...ading.html has more detailed information.
[eluser]sirwan.me[/eluser]
@falkencreative. I am calling it twice in my above code. in the block of code for the picture i call it : Code: if(!$this->upload->do_upload("picture")){ and the block of code for the zip i call it: Code: if(!$this->upload->do_upload("file")){ isnt it where Im putting "picture" or "file" changing it from the default userfile ?
[eluser]sirwan.me[/eluser]
Ah I done it! basically I have to reinilize the config array and load the library ONLY ONCE! load the library once above. and the after the config arrays, inializite the config, with the inilizite function.
|
Welcome Guest, Not a member yet? Register Sign In |