| | |
Uploading multiple Images through input type="file"
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
I have a starting base and I had the idea of using an array name similar to the checkboxes where you would use checkbox[] and let it repeat through a for loop, in this case file[]. But when I go to access it via $_FILES['file[$index]']['name'] it errors. I think there is something wrong with my logic as it is looking wrong but I feel it should work
Any Ideas?
Thanks, Regards X
Any Ideas?
Thanks, Regards X
Thanks Nav33n to the PHP rescue 
Theres way too much code to copy n paste so I will try break it up best I can, code:
Thats the nuts of my code im trying to get working. (This works)
But im trying to make the type="file" an array id/name so its like id="file[]" name="file[]".
Then call it again at $_FILES['file[index]']['name']; using a for loop using 'index'.
Anyways no luck ill try again in the morning, any ideas?
Thanks Again, Regards X

Theres way too much code to copy n paste so I will try break it up best I can, code:
PHP Syntax (Toggle Plain Text)
switch($_POST['submit']) { case 'UPLOAD': now a whole bunch of code access variables and databases then $file = $_FILES['file']['name']; again a whole bunch of code } <input type="file" id="file" name="file"> <input type="submit" id="submit" name="submit" value="UPLOAD">
Thats the nuts of my code im trying to get working. (This works)
But im trying to make the type="file" an array id/name so its like id="file[]" name="file[]".
Then call it again at $_FILES['file[index]']['name']; using a for loop using 'index'.
Anyways no luck ill try again in the morning, any ideas?
Thanks Again, Regards X
Last edited by OmniX; Jan 12th, 2008 at 8:49 am.
php Syntax (Toggle Plain Text)
<?php if(isset($_POST['submit'])) { for($i=0;$i<count($_FILES['fileupload']);$i++) { print $_FILES['fileupload']['name'][$i]."<br />"; } } ?> <html> <body> <form name="upload" method="post" action="upload.php" enctype="multipart/form-data"> <table> <tr><td> <input type="file" name="fileupload[]"> </td></tr> <tr><td> <input type="file" name="fileupload[]"> </td></tr> <tr><td> <input type="file" name="fileupload[]"> </td></tr> <tr><td> <input type="file" name="fileupload[]"> </td></tr> <tr><td> <input type="submit" name="submit"> </td></tr> </table> </form> </body> </html>
This works for me!
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
Man I dont know what to say...
Your a PHP Guru,who has come to the rescure and helped me so much time and time again.
Same concept worked on my webpage first time.
Thankyou =)
PS: I was just wondering what is the different between using isset and just $_POST[] because i was reading at php.net and couldnt understand anything but only if you wanted to pass a variable?
Your a PHP Guru,who has come to the rescure and helped me so much time and time again.
Same concept worked on my webpage first time.
Thankyou =)
PS: I was just wondering what is the different between using isset and just $_POST[] because i was reading at php.net and couldnt understand anything but only if you wanted to pass a variable?
You are welcome! I am not a guru! There are sooooo many things that I am not aware of.isset() checks whether a variable is set, has a value (even null) in it. So, this would pass the value of that variable, only if its set.
if(isset[$_POST['name'])){
$name=$_POST['name'];
} else {
echo "Name is not set.";
}
As I said, If you assign null to a variable and check if it is set, it would return true.
$x="";
if(isset($x)){
echo "X is set";
} else {
echo "X is not set.";
}
In this case, it returns X is set, even though it doesn't have any value.
Cheers,
Naveen
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Other Threads in the PHP Forum
- Previous Thread: PHP Developers NEEDED!
- Next Thread: Uploading only certain images (jpeg, jpg, etc)
| Thread Tools | Search this Thread |
301 apache api array autosuggest beginner binary broken cakephp checkbox class cms code compression cron curl data database date display dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google href htaccess html httppost if...loop image include insert ip javascript joomla jquery key library limit link links login mail md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf pdfdownload php phpvotingscript problem query radio random recursion remote screen script search searchbox server session sessions sms sorting source space sql syntax system table tutorial update upload url validator variable video volume votedown web website youtube zend






