I need help to make this, It download the file on my server when refresh but I want that it should start download on button click. Here is my code
//File to save the contents to
$fp = fopen ('files2.tar', 'w+');
$url = "http://localhost/files.tar";
//Here is the file we are downloading, replace spaces with %20
$ch = curl_init(str_replace(" ","%20",$url));
//give curl the file pointer so that it can write to it
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);//get curl response
//done
curl_close($ch);
How to I make a button that download file on click. I know I need to make a function that execute on click but I don't know how to start. If need it can use javascript or jquery Thanks in advance.