Anyone can provide me the simple code snippet of Codeigniter to upload 2 images at a time (2 different Input field of course). I have to upload two images at once, or one after another, both the images should be in different places.
I tried to make it myself by calling the upload function twice, but returned the previous images with these extensions: * .jpg.jpg
Anybody can help
Unfortunately the CodeIgniter upload class is more than one Although the file does not support, you can use standard PHP functions.
& lt; Form enctype = "multipart / form-data" verb = "/ upload / send" method = "post" & gt; & Lt; Input type = "hidden" name = "MAX_FILE_SIZE" value = "30000" /> Send this file: & lt; Input name = "a_file" type = "file" /> & Lt; Br / & gt; Send another file: & lt; Input name = "another_file" type = "file" / & gt; & Lt; Br / & gt; & Lt; Input type = "submit" value = "send files" / & gt; & Lt; / Form & gt;
Then do something like this in the administrator:
Class Upload Controller {Function Upload} (parent :: controller (); } Function index () {$ data = array (); $ This- & gt; Load-> View ('template / head'); $ This- & gt; Load-> View ('Upload', $ data); $ This- & gt; Load-> Scene ('template / foot'); } Send the function () {// TODO: Check the error ['name'] to prevent hacks, and refine http://www.php.net/manual/en/features.file-upload.errors. Php move_uploaded_file ($ _FILES ['a_file'] ['tmp_name'], '/path/to/uploads/'._$_FILES['a_file'[['name']); Move_uploaded_file ($ _FILES ['another_file'] ['tmp_name'], '/path/to/uploads/'.$_FILES['another_file'[['name']); }}
Comments
Post a Comment