Latavish's Multiple Image Upload with Thumbnail Generation - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Latavish's Multiple Image Upload with Thumbnail Generation (/showthread.php?tid=8682) |
Latavish's Multiple Image Upload with Thumbnail Generation - El Forum - 05-27-2008 [eluser]Latavish[/eluser] Latavish's Multiple Image Upload w/ Thumbnail Generation Hi CI lovers, I hope you guys had a GREAT and EXTENDED weekend. Been working on this for a few days now and finally finished up this weekend and wanted to share my work with this great community. Now this code is really customizable so feel free to trick it out to fit your needs. Code may not be perfect because I designed this to fit my needs on a project that i'm doing. (a nice CMS) If you find this code useful all I require is a simple thanks! TeeHee!! :-) Happy Coding... Features: Upload Multiple Images at once Automatically Renames Images to a random name (protects file from being overwritten) Adds Image Information to DB C O N T R O L L E R Code: class Upload extends Controller { M O D E L Code: class Process_image extends Model { Latavish's Multiple Image Upload with Thumbnail Generation - El Forum - 06-09-2008 [eluser]webbymonk[/eluser] Thanks for this code... I try it but it didn'working or maybe is there something wrong with my view file? ----------------------------------------------------------------- <form action="http://192.168.1.133/neo/index.php/neomin/picupload" method="post" enctype="multipart/form-data"> <input type="file" name="key" size="20" /> <input type="file" name="key2" size="20" /> <input type="file" name="key3" size="20" /> <input type="submit" value="upload" /> </form> ----------------------------------------------------------------- Latavish's Multiple Image Upload with Thumbnail Generation - El Forum - 07-11-2008 [eluser]webbymonk[/eluser] Thanks lavatish, finally i can make it works... here is my code Controller Code: function upload_tour_pic() { now I think i want to add some fields for the image, like title and description... Do anyone have idea how to loop array of fields and insert it into database.. For example: image1 - title1 - desc1 image2 - title2 - desc2 image3 - title3 - desc3 Code: <input type="text" name="pic_title[]" value="" /> Thanks... Latavish's Multiple Image Upload with Thumbnail Generation - El Forum - 07-12-2008 [eluser]Asinox[/eluser] Nice code Thanks Latavish's Multiple Image Upload with Thumbnail Generation - El Forum - 07-14-2008 [eluser]Mitja[/eluser] Hi, very nice tutorial but i have problemm Code: foreach($_FILES as $key => $value) if ( !$this->upload->do_upload($key)) show me an error of Quote:A PHP Error was encountered View is: <tr><td>Fotka: <input type="file" name="pluspayment_title_photo[]" /></tr> what i am doing wrong? Latavish's Multiple Image Upload with Thumbnail Generation - El Forum - 08-08-2008 [eluser]jdgiotta[/eluser] I'm using your example in my application, but every once in a while the files get confused. The user choose 3 files for 3 different purposes and each are moved to their own respective folder. Yet, for some reason files become mismatched intermittently. Has anyone experienced this? Latavish's Multiple Image Upload with Thumbnail Generation - El Forum - 08-21-2008 [eluser]donpepito[/eluser] [quote author="Mitja" date="1216061134"]Hi, very nice tutorial but i have problem[/quote] Hi! Instead of checking this: Code: if (!empty($key['name'])) { try this: Code: if (!empty($value['name'])) { In this case don't use array in file upload fields, add a counter after them: Code: <input type="file" name="userfile_1" /> Latavish's Multiple Image Upload with Thumbnail Generation - El Forum - 08-21-2008 [eluser]Xeoncross[/eluser] [quote author="donpepito" date="1219334838"] try this: Code: if (!empty($value['name'])) { Why do people even waste CPU time on the empty function? Just switch to boolean: Code: if($value['name']) { Latavish's Multiple Image Upload with Thumbnail Generation - El Forum - 08-21-2008 [eluser]Rick Jolly[/eluser] [quote author="Xeoncross" date="1219368396"][quote author="donpepito" date="1219334838"] try this: Code: if (!empty($value['name'])) { Why do people even waste CPU time on the empty function? Just switch to boolean: Code: if($value['name']) { It's not the same thing. From the php manual: Quote:empty() is the opposite of (boolean) var, except that no warning is generated when the variable is not set. So this produces an undefined index error: Code: if (! $_POST['does_not_exist']) // undefined index error Code: if (empty($_POST['does_not_exist'])) // no error Latavish's Multiple Image Upload with Thumbnail Generation - El Forum - 08-21-2008 [eluser]Xeoncross[/eluser] [quote author="Rick Jolly" date="1219369891"] So this produces an undefined index error: Code: if (! $_POST['does_not_exist']) // undefined index error Code: if (empty($_POST['does_not_exist'])) // no error I was assuming you were using a set variable as it is bad practice to just "assume" one is set/unset. But that is right. |