title: Cancel cURL request with PHP
body: <p>I am trying to cancel an already started cURL request with PHP. Since I have struggeled finding a good solution I am stuck now with an unlink function that does infact not work since cURL is downloading the content.  </p>
  
  <pre><code>unlink(/foobar/foo.txt): Resource temporarily unavailable in /project/delete.php on line 16
  </code></pre>
  
  <p>This code is where I am stuck now:</p>
  
  <pre><code>unlink($fileLocation);
  </code></pre>
  
  <p>Since I am not experienced with cURL I am not sure how I can manage to stop the cURL request that is done in my downloading part:</p>
  
  <pre><code>$ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($ch, CURLOPT_NOPROGRESS, false);
  curl_exec($ch);
  </code></pre>
  
  <p>What basically is the usecase: A user downloads a file and should also have the possibility to cancel the download. How can I manage to do that?</p>