hi,
i have a form which includes
<INPUT TYPE=\"file\" NAME=\"File[]\">
This allows users to upload any number of files at once. After the form has been posted, i do the following :
$_POST[File] = $_FILES[File][name];
@copy($_FILES[File][tmp_name], $Location.$_FILES[File][name]);
while ((list($k,$v) = each($_POST[File])) && (list($k,$w) = each($_POST[Title])))
{
$sql= "insert into $files_table (FileType_Id, secondarytype_id, Product_Id, FileName, Title, Description, ModifiedDate, Author_Id)
VALUES ('', '', '', '$v', '$w', '', '', '')";
$result = @mysql_query($sql,$connection) or die(mysql_error());
$sql = "SELECT ID, FileName FROM $files_table
WHERE FileName = '$v'";
$result2 = @mysql_query($sql,$connection) or die(mysql_error());
$num = @mysql_num_rows($result2);
if ($num != 0)
{
while ($row = mysql_fetch_array($result2))
{
$file_id = $row['ID'];
}
}
$sql= "insert into $tf_associations_table (file_id, topic_Id)
VALUES ('$file_id', '$_POST[topic_id]')";
$result3 = @mysql_query($sql,$connection) or die(mysql_error());
}
$Message = "<div class=Update>CMS UPDATE - The file(s) were uploaded and attached successfully</div>";
header("Location: http://$host$uri/$Page_Title?show=View&Message=$Message");
exit;
}
the issue is that the @copy part does not copy the file, it seems to be because $_POST[File] is an array. i am not sure how to deal with this effectively, so that all uploaded files are copied correctly, any thoughts? if i remove the [] part from the input part of the form, i.e. drop the array, it works fine except that multiple files would not be handled. the database parts work fine, in so far as all tasks are executed correctly and the data is stored as expected, it's just the mass file copying which fails. i think i need to do some stuff with the array, i'm just not sure what, and ain't figured it out yet, despite alot of testing.
your help would be greatly appreciated.