Multiple upload function |
[eluser]Référencement Google[/eluser]
Hi, I give a piece of code that can be usefull for some people that will want to take the time understanding the function. It upload files coming from a multiple upload form and if all ok return a files array, other wise delete the uploaded files from server. It's sure far from perfect and I release it as is, it's part of an application I have developped, so if you are interrested about use this function, you must of course adapt it for your application. Also note that I will answer basic questions about it, but I won't give any other kind of support for this. Code: function multiple_upload($upload_dir = 'uploads', $config = array()) Sample usage: Code: if( ! $files = $this->upload->multiple_upload('public/photos'))
[eluser]CARP[/eluser]
Hi Too Pixel I've tried your library, and worked great! But, how would you modify its code for example to Allow user to submit from 1 to 5 images. I mean, I've made a userfile[] set of 5 upload fields in my form, the first one is mandatory, but the other 4 not. But when I use your lib, I get errors, because it requires the user to select 5 images, 1 for each upload field... Thanks a lot in advance,
[eluser]Référencement Google[/eluser]
Here is a sample part of a form that I use with this library Code: <?php
[eluser]CARP[/eluser]
Puff! Just naming the upload fields from userfile[] to userfile1, userfile2... etc. solved the problem!! 1. I thought the upload files should be named userfile 2. and that they had to been toghether in an array... Thanks!
[eluser]Unknown[/eluser]
Thanks for this script! Great it's work, I can uploading more than one images in one time but I got a problem when I try uploading some zip and pdf file,
[eluser]pistolPete[/eluser]
[quote author="chero" date="1235136815"]I got a problem when I try uploading some zip and pdf file[/quote] You have to adjust Code: $config['allowed_types'] = 'gif|jpg|jpeg|jpe|png';
[eluser]Unknown[/eluser]
Conditional not need: Code: if( ! empty($value['name']))
[eluser]Référencement Google[/eluser]
[quote author="lusever" date="1235404723"]Conditional not need: Code: if( ! empty($value['name'])) Yes that's right, thanks for seeing this one.
[eluser]artlover[/eluser]
thanks for great code. but I also need to save it to database. so I need the name of files :/ how can I get the names? ps, if there is already same named file at folder, it automatically rename the file... in this case, I need renamed file name :/ appreciate helps!! |
Welcome Guest, Not a member yet? Register Sign In |