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'] 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

Can you show us your script ? What is the error that you are getting ?

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:

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']; using a for loop using 'index'.

Anyways no luck ill try again in the morning, any ideas?

Thanks Again, Regards X

<?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! :)

commented: Gave me a working example +1

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?

:) 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

Ahhh ok Thankyou once again, off to read my other thread that you answered =P

Can u please give me whole code for multiple images uploading in php.. i have tried.. but its not working... plz plz help me.. its very urgent.. plz reply as soon as possible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.