PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
anjanesh
DevNet Resident
Posts: 1679 Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India
Post
by anjanesh » Mon Aug 09, 2004 11:13 pm
I have this is code for mutiple file uploads :
Code: Select all
<?php if (isset($_POST['hiddenFile'])) echo count($_FILES['HousePhotos']); ?>
<FORM ACTION="" METHOD=POST NAME="frm" ENCTYPE="multipart/form-data">
<INPUT TYPE=hidden NAME="hiddenFile">
<TABLE>
<?php
for ($i=0;$i<10;$i++)
{
?>
<TR><TD>Photo <? echo ($i+1); ?> : </TD><TD><INPUT TYPE="file" NAME="HousePhotos[]"></TD></TR>
<?
}
?>
<TR><TD><INPUT TYPE=submit NAME=subMit VALUE=Send></TD></TR>
</TABLE>
</FORM>
echo count($_FILES['HousePhotos']); is always displaying 5. I even tried using 10 html lines of <INPUT TYPE="file"> and still it shows 5.
Anyidea how to have this fixed ?
Thanks
Last edited by
anjanesh on Tue Aug 10, 2004 1:00 am, edited 1 time in total.
phice
Moderator
Posts: 1416 Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:
Post
by phice » Tue Aug 10, 2004 12:18 am
Have you tried doing something like...
Code: Select all
print "<pre>\n";
print_r($_FILES);
print "</pre>\n";
and see what that gets you?
anjanesh
DevNet Resident
Posts: 1679 Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India
Post
by anjanesh » Tue Aug 10, 2004 12:55 am
Its showing this (I just edited the indentation for posting here and did not enter any fields in the file box) :
Code: Select all
Array (
їHousePhotos] =>
Array (
їname]=>Array (ї0]=> ї1]=> ї2]=> ї3]=> ї4]=> ї5]=> ї6]=> ї7]=> ї8]=> ї9]=> )
їtype]=>Array (ї0]=> ї1]=> ї2]=> ї3]=> ї4]=> ї5]=> ї6]=> ї7]=> ї8]=> ї9]=> )
їtmp_name]=>Array ( ї0]=> ї1]=> ї2]=> ї3]=> ї4]=> ї5]=> ї6]=> ї7]=> ї8]=> ї9]=> )
їerror]=>Array (ї0]=> 4 ї1]=> 4 ї2]=> 4 ї3]=> 4 ї4]=> 4 ї5]=> 4 ї6]=> 4 ї7]=> 4 ї8]=> 4 ї9]=> 4)
їsize]=>Array (ї0]=> 0 ї1]=> 0 ї2]=> 0 ї3]=> 0 ї4]=> 0 ї5]=> 0 ї6]=> 0 ї7]=> 0 ї8]=> 0 ї9]=> 0)
)
)
The error values are showing up as 4 which is normal because no file was uploaded.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Aug 10, 2004 12:57 am
that's functioning correctly..
anjanesh
DevNet Resident
Posts: 1679 Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India
Post
by anjanesh » Tue Aug 10, 2004 1:00 am
Oh. Its ok. Got it. count ($_FILES['HousePhotos']) will always return 5 because there are only 5 arrays in them. I had to do $_FILES['HousePhotos']['name'] to return the total number of files input boxes.