I Am trying to delete a file that is being replaced with a new file upload, However i am using unlink an i get the error RESOURCE TEMP UNAVAILABLE
tried to wait for a few seconds before trying to unlink. tried unsetting the temp file
if (isset($_POST['oldimagesrc'])){ $oldimagesrc=$_POST['oldimagesrc'];
$oldimagesrc = filter_var($oldimagesrc, FILTER_SANITIZE_STRING);
$oldimagesrc = strip_tags($oldimagesrc);
$dir="../imageupload/images/";
$oldimagelocation = $dir.$oldimagesrc;
$tempfile=$_FILES["image"]["tmp_name"];
if (move_uploaded_file($tempfile,$newimagelocation)) {
if (unlink($oldimagelocation)) {
die($savetoDB);
exit();
}
else
{
die("Could Not Delete File");
exit();
}
}
I would hope there is some work around like a way to clear the cached file allthough i have tried to unset the temp file..
P.S
Sometimes it works while other times i get the error...