Re: $_FILES help. Counting help

From: Date: Tue, 27 May 2003 23:48:58 +0000
Subject: Re: $_FILES help. Counting help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-149175@lists.php.net to get a copy of this message
Didier, My guess is in your HTML, you have the input(s) named as 'file'.. Because of the way that PHP handles it's POST/GET variables, you will want to redeclare your input names in your HTML to 'file[]'... This basically defines that it is an array.. Hope that helps, Jordan Didier McGillis wrote:
I have three file fields in a form. I need it to upload those three items or two or one. I can get it to upload one, but not all three, habing trouble with the for loop and how I get a value of $i. if(isset($_POST['upload'])){ if (!empty($_FILES['file']['name'])){
           $formats = array('mp3','exe');
           if(in_array(strtolower(substr($_FILES['file']['name'],-3)),$formats)) {
               echo "<font face=\"verdana,arial,helvetica\" size=\"2\" color=\"#000000\"><b>Sorry! MP3's and .EXE's are disallowed!</b></font>";
           }else{
               //mkdir("upload/" . $_POST['dir'],0777);
               copy($_FILES['file']['tmp_name'], "images/" . $_FILES['file']['name']);
               unlink($_FILES['file']['tmp_name']);
               echo "<font face=\"verdana,arial,helvetica\" size=\"2\" color=\"#000000\"><b>".$i." File(s) Uploaded Successfully to <b>" . $_POST['dir'] . "</b> directory!</b></font>";
           }
}else{
       echo "<font face=\"verdana,arial,helvetica\" size=\"2\" color=\"#000000\"><b>You must specify a file to upload</b></font><br>\n";
       echo "<font face=\"verdana,arial,helvetica\" size=\"2\" color=\"#000000\"><a href=\"javascript:history.back()\">< < back</a></font><br>\n";
       exit();
} } $i =$_FILES['file']['name']; is it for ($i=1;$i<4;i++) { run code } or am I way off, help please. thanks, _________________________________________________________________ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail


« previous php.general (#149175) next »