I'm trying to delete a file after it is uploaded via a form and processed:
// FORM SUBMIT
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$uploadfile = getcwd() . '/pub/media/dealers/' . basename($_FILES['proof']['name']);
move_uploaded_file($_FILES['proof']['tmp_name'], $uploadfile);
// Upload attachment to Zendesk
$attachment = $client->attachments()->upload([
'file' => $uploadfile
]);
unlink($uploadfile);
exit;
}
I receive the following error:
Error filtering template: Warning: unlink(C:....\MyFile.txt): Resource temporarily unavailable
If I remove the $attachment
upload code, then the file is deleted as expected. So I've tried the following, but receive the same Temporarily Unavailable error:
$attachment = $client->attachments()->upload([
'file' => $uploadfile
]);
unset($attachment);
unlink($uploadfile);
Am I missing something?