I'm writing a php script. In download part I have to redirect an url to start download. However, when I click the button .jpg files are opened in the new tab. How can I convert it to download format.
<?php
$url= @$_GET['url'];
function redirect($url){
if (headers_sent()){
die('<script type="text/javascript">window.location=\''.$url.'\';</script>');
}else{
header('Location: ' . $url);
die();
}
}
redirect($url);