1
Beginners - Learning PHP / Re: Can't upload the same file twice
« on: June 01, 2012, 12:14:14 PM »
Found the problem. The delete variable returned the $_GET function needed to be cleared before the next upload. Thanks again Ojoshiro for your input. For anyone else with a similar problem the following code works.
PHP Code: [Select]
if(isset($_POST['upload']))
{
//clear 'delete' variable from previous delete operation
$_GET["delete"]=NULL;
$uploadDir="../gallery/";
$fileName = $_FILES['file']['name'];
$tmpName = $_FILES['file']['tmp_name'];
$fileSize = $_FILES['file']['size'];
$fileType = $_FILES['file']['type'];
$filePath = $uploadDir . $fileName;
$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error uploading file";
exit;
}
}
