How do I loop something like this?

From: Date: Thu, 17 Oct 2002 18:14:27 +0000
Subject: How do I loop something like this?
Groups: php.general 
Request: Send a blank email to php-general+get-120494@lists.php.net to get a copy of this message
I've got an upload form: <form action="upload.php" method="post" enctype="multipart/form-data" name ="upload" id="upload"> <p align="center">Upload a file <input type="file" name="upfile"> </p> <p align="center"> <input name="MAX_FILE_SIZE" type="hidden" id="MAX_FILE_SIZE" value ="100000"> <input name="submit" type="submit" id="submit" value="upload this file"> </p> </form> and the pagewith a php script to handle it: <html> <head> <title>uploading file</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <p><img src="images/niles_logo_plain.gif" width="75" height="95"> </p> <p>&nbsp;</p> <p align="center">Uploading File...</p> <? if ($upfile=="none") { echo "no file selected for upload"; exit; } if ($upfile_size==0) { echo "No data was transferred, your file may be too large or may not exist"; exit; } if (!is_uploaded_file($upfile)) { echo "file may contain upload attack"; exit; } $okfile="/var/www/html/files/".$upfile_name; if ( !copy($upfile, $okfile)) { echo "Could not move file"; exit; } echo "File uploaded successfully<BR><BR>"; $fp = fopen($okfile, "r"); $contents = fread ($fp, filesize ($okfile)); fclose($fp); $fp = fopen($okfile, "w"); fwrite($fp, $contents); fclose($fp); echo "<HR>"; echo "you can link to your file at: <A HREF=http://red.niles.net/files/$upfile_name>http://red.niles.net/files/$upfile_name</A>"; ?> </body> </html> That works fine... but I've been trying for days to figure out how to add, let's say three fields to the upload form... I'd rename the "upfile" form element "upfile1", "upfile2", etc... now it seams like I could do a for loop adding a number on to each variable, but I've tried a dozen things which seemed like a good idea at the time, but didn't work... what should the syntax for such a thing look like? Michael

« previous php.general (#120494) next »