file upload in multiple paths - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: file upload in multiple paths (/showthread.php?tid=11677) |
file upload in multiple paths - El Forum - 09-19-2008 [eluser]PHP Programmer[/eluser] I am trying to upload files in two different paths by residing in a single form. I have two fields - Photo Uplaod (Requires .jpg|.gif|.png ) and Resume Upload (Requires .doc|.rtf) I am trying following: View <?php echo form_open_multipart('upload/do_upload');?> <input type="file" name="userfile" size="20" /> <input type="file" name="testfile" size="20" /> <br /><br /> <input type="submit" value="upload" /> </form> Controller function do_upload() { $config['upload_path'] = './uploads/file1/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '100'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $config1['upload_path'] = './uploads/file2/'; $config1['allowed_types'] = 'gif|jpg|png'; $config1['max_size'] = '100'; $config1['max_width'] = '1024'; $config1['max_height'] = '768'; $this->load->library('upload', $config); $this->load->library('upload', $config1); $this->upload->initialize($config); $this->upload->initialize($config1); if ( ! $this->upload->do_upload()) { $error = array('error' => $this->upload->display_errors()); $this->load->view('upload_form', $error); } else { $data = array('upload_data' => $this->upload->data()); $this->load->view('upload_success', $data); } } But it is not uploading the files in both folders (file1 and file2). How can I solve this problem? file upload in multiple paths - El Forum - 09-19-2008 [eluser]xwero[/eluser] You can only load a library once and adding two initialize methods you just overwrite one setting array with the other. You have to use a loop to make this happen. The file fields can't be named userfile so you have to use separate names. Code: // view file upload in multiple paths - El Forum - 09-19-2008 [eluser]PHP Programmer[/eluser] thanx....it worked!! file upload in multiple paths - El Forum - 09-19-2008 [eluser]PHP Programmer[/eluser] Also, 1 more addition in my prev question: How to upload video along with the above two files?? file upload in multiple paths - El Forum - 09-19-2008 [eluser]xwero[/eluser] video is also a file so you could add it but because video is most of the time a pretty big file so it's going to take long to upload it. I would suggest they upload it to a video service and they add the link to the video |