Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Photo upload problem

Status
Not open for further replies.

Bastien

Programmer
Joined
May 29, 2000
Messages
1,683
Location
CA
HI guys,

Having some issues here uploading multiple images. The code below illustrates what I need to do. Allow users to upload up to 5 images at one time.

The problem:
The PHP code below is supposed to grab the images via the $_FILES['photos'], which is the array of images...

All I want to do so far is see if there are images, another page will handle the copying etc to the correct dirs.

I just can't get the count of the number of files, what the value of count($photos_uploaded) should be...

Any ideas?

Code:
the php code to look at the number of files
<?
$photos_uploaded = $_FILES['photos'];

 echo "<br>photos:".count($photos_uploaded);
if (count($photos_uploaded)>0){ $photos = "1"; }

?>

the relevant portion of the form...
<form name="form1" method="post" action="{$_SERVER['PHP_SELF']}" enctype="multipart/form-data">
...
			<td><font color="#000000" size="-1" face="Arial, Helvetica, sans-serif">Main
					Picture</font></td>
			<td><input name="photos[]" type="file" id="dealers_mainpic" size='32'>
				<font color="#000000" size="-1" face="Arial, Helvetica, sans-serif">(max.
			150 KB)</font></td>
		</tr>
		<tr>
			<td><font color="#000000" size="-1" face="Arial, Helvetica, sans-serif">Additional
					Pic</font></td>
			<td><input name="photos[]" type="file" id="dealers_pic2" size='32'> <!--AMEND HERE -->
				<font color="#000000" size="-1" face="Arial, Helvetica, sans-serif">(max.
			150 KB)</font>										</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td><input name="photos[]" type="file" id="dealers_pic3" size='32'> <!--AMEND HERE -->
				<font color="#000000" size="-1" face="Arial, Helvetica, sans-serif">(max.
			150 KB)</font>										</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td><input name="photos[]" type="file" id="dealers_pic4" size='32'> <!--AMEND HERE -->
				<font color="#000000" size="-1" face="Arial, Helvetica, sans-serif">(max.
			150 KB)</font>										</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td><input name="photos[]" type="file" id="dealers_pic5" size='32'> <!--AMEND HERE -->
				<font color="#000000" size="-1" face="Arial, Helvetica, sans-serif">(max.
			150 KB)</font>										</td>
		</tr>
	</table>
	<pre> 					 <input name="Submit_dealers" type="submit" id="Submit_dealers" value="Submit">  <input name="Reset_dealers" type="reset" id="Reset_dealers" value="Reset"> 							</pre>
</form>

TIA

Bastien

Cat, the other other white meat
 
Using a test HTML page:

Code:
<html><body>
	<form method="post" action="test_showfiles.php" enctype="multipart/form-data">
		<input name="photos[]" type="file"><br>
		<input name="photos[]" type="file"><br>
		<input name="photos[]" type="file"><br>
		<input name="photos[]" type="file"><br>
		<input name="photos[]" type="file"><br>
		<input type="submit">
	</form>
</body><html>

test_show_files.php consists of:
Code:
<?php
print '<pre>';
print_r ($_FILES);
?>

Using Opera to point to a LAMP (RH9/2.0.50/4.0.17/5.0.0), when I select three files and submit, I get:

Code:
Array
(
    [photos] => Array
        (
            [name] => Array
                (
                    [0] => test_foo.html
                    [1] => firewall_script.sh
                    [2] => index.htm
                    [3] => 
                    [4] => 
                )

            [type] => Array
                (
                    [0] => text/html
                    [1] => application/x-sh
                    [2] => text/html
                    [3] => 
                    [4] => 
                )

            [tmp_name] => Array
                (
                    [0] => /tmp/php9aObpl
                    [1] => /tmp/phpJNHrcD
                    [2] => /tmp/php3HEJZU
                    [3] => 
                    [4] => 
                )

            [error] => Array
                (
                    [0] => 0
                    [1] => 0
                    [2] => 0
                    [3] => 4
                    [4] => 4
                )

            [size] => Array
                (
                    [0] => 2739
                    [1] => 3697
                    [2] => 189340
                    [3] => 0
                    [4] => 0
                )

        )

)

On my machine, the count($_FILES) will always be 5.

What do you get in $_FILES?


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I get 0. It just doesn't make sense why I am not getting anything...

BTW the OS is win2K with IIS..could it be an iis issue not allowing uploads?

Bastien

Cat, the other other white meat
 
fine, on and 2M, none of the images is that big


Bastien

Cat, the other other white meat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top