title: PHP: Unlink resource temporarily unavailable
body: <p>I'm trying to delete a file after it is uploaded via a form and processed:</p>
  
  <pre><code>// 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-&gt;attachments()-&gt;upload([
        'file' =&gt; $uploadfile
      ]);
  
      unlink($uploadfile);
      exit;
  }
  </code></pre>
  
  <p>I receive the following error:</p>
  
  <blockquote>
    <p>Error filtering template: Warning:
    unlink(C:....\MyFile.txt): Resource
    temporarily unavailable</p>
  </blockquote>
  
  <p>If I remove the <code>$attachment</code> upload code, then the file is deleted as expected. So I've tried the following, but receive the same Temporarily Unavailable error:</p>
  
  <pre><code>$attachment = $client-&gt;attachments()-&gt;upload([
      'file' =&gt; $uploadfile
    ]);
  
  unset($attachment);
  unlink($uploadfile);
  </code></pre>
  
  <p>Am I missing something?</p>