Page 1 of 1

[SOLVED] file upload error ($_FILE)

Posted: Thu Sep 16, 2004 2:21 pm
by m_m
For some reason, when i try and upload a file, the $_FILE or $HTTP_POST_FILE array holds the info, but i can't extract it. It works fine when i am only uploading 1 file @ a time, but errors (and by error i mean, nothing is printed) with multiple. I'll expalin..

here is a snipet of code i am using to test the file upload

Code: Select all

$num_files = count($_FILES['IMG']['name']);

	for($x = 0; $x < $num_files; $x++)
	{ 
		echo "the files you picked are...<br>";
		echo $_FILES['IMG']['name'][$x];
	}
the HTML form code..

Code: Select all

&lt;form action="upload.php" method="POST" enctype="multipart/form-data"&gt;
&lt;input type="hidden" name="MAX_FILE_SIZE" value="200000" /&gt;&lt;br&gt;
File:&lt;input name="IMG" type="file" /&gt; &lt;br&gt;
File:&lt;input name="IMG" type="file" /&gt; &lt;br&gt;
File:&lt;input name="IMG" type="file" /&gt; &lt;br&gt;
File:&lt;input name="IMG" type="file" /&gt; &lt;br&gt;
...
&lt;input type="submit" value="Upload Files" /&gt;
&lt;form&gt;
when the form is submitted, the first echo line is printed ("the files.."), but thats it. Nothing happens with the rest. I am selecting files and I know they are in there when i do a print_r() on the array.

For some odd reason, it prints nothing wnen i use the [$x].

any ideas why this happens?

Posted: Thu Sep 16, 2004 2:28 pm
by dethron
you are using same name, for all of your input values. this does not make them and array, instead one replaces others.
you must use different names for your input-tags.

Posted: Thu Sep 16, 2004 2:31 pm
by feyd

Code: Select all

name="IMG&#1111;]"

Posted: Thu Sep 16, 2004 4:04 pm
by m_m
stupid mistakes.

thanks!