Uploading multiple files with FOR

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Perfidus
Forum Contributor
Posts: 114
Joined: Sun Nov 02, 2003 9:54 pm

Uploading multiple files with FOR

Post by Perfidus »

I'm trying to upload a single file to different folders by using a for loop, but I only manage to introduce one.
Why?
Any hints ?

Code: Select all

$newarray = array_values($values);
$total=count($newarray);
$todaydate= date("Y-d-m");
for($i=0; $i<$total; $i++){
$values2=$newarray[$i];
$uploadDir = "../requested/".$values2."/";
$uploadFile = $uploadDir . $_FILES['userfile']['name'];
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile))
{
$sql=mysql_query("UPDATE Units SET internaldate='$todaydate' WHERE ip='$values2'", $connect) or die(mysql_error().'<p>'.$sql.'</p>'); 
}}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

move_uploaded_file() moves files. use move_uploaded_file() to make the initial move, then copy() the others from that.
Post Reply