Upload multiple files
| From: | Antti | Date: | Sat, 18 Jan 2003 11:47:12 +0000 |
| Subject: | Upload multiple files | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-132085@lists.php.net to get a copy of this message | ||
I want to do this for multiple files. I tried to do this with a foreach -loop but I think I made some mistakes with the array "userfile". In this example userfile is just the "name" in the input tag. When uploading multiple files userfile is -ofcourse- an array like this: name='userfile[]'. Now I want to know how to handle with that array in somekind of a loop. For one file the script is this:
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
$namename=$_FILES['userfile']['name'];
move_uploaded_file($_FILES['userfile']['tmp_name'],"/path/$namename");
if (rename("/path/$namename", "/path/$uartist-$usong.mp3"))
{
$query = "INSERT INTO table (column1,column2,column3) values ('$value1','$value2','$value3')";
mysql_query($query) or die ("Couldn't make query!");
print "File Upload and rename succesful!";
} else { print "File Upload failed!"; }
}
antti