Here is a short script:
The problem is: When the user has selected a file, the selected file will be shown at the page. When the user click [Remove] link, it will execute a javascript an reload POST the value to the same page again passing "deleteID". At this moment, I try to copy() again, but this time is failed.
if ($HTTP_POST_FILES["upload_file"]["name"] != "") {
$_SESSION['upload_array'][] = $HTTP_POST_FILES["upload_file"];
for ($i = 0 ; $i < count($_SESSION['upload_array']) ; $i++) {
print $_SESSION['upload_array'][$i]["name"]." <a href='javascript:removeAttachment(".$i.")'>[Remove]</a>"."<br>";
[B]// this is ok[/B]
copy($_SESSION["upload_array"][$i]["tmp_name"], $_SESSION["upload_array"][$i]["name"]);
}
}
if ($POST['deleteID'] != "") { // when delete the array
for ($i = 0 ; $i < count($SESSION['upload_array']) ; $i++) {
// when the page is reload by POST, this copy is failed
copy($SESSION["upload_array"][$i]["tmp_name"], $SESSION["upload_array"][$i]["name"])) {
}
}