$_FILES help. Counting help
| From: | Didier McGillis | Date: | Tue, 27 May 2003 22:50:58 +0000 |
| Subject: | $_FILES help. Counting help | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-149173@lists.php.net to get a copy of this message | ||
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