How do Curl stop running?

Asked

Viewed 231 times

1

I’m using a Curl to download a file... but there is a problem that when the user gives a refresh on the page or for the upload the download continues happening in the background. How do I stop the download execution?!

$url = 'http://www.sitelab.combr.co/backup.rar';


$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

$fp = fopen('backup.rar', 'w');
            curl_setopt($ch, CURLOPT_FILE, $fp);


$result = curl_exec($ch);
curl_close($ch);
fclose($fp);
if(!$result){
                echo 'False';
                exit;
            }else{
                echo 'True';
                exit;
            }
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.