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 formation. Here is my php redirect code;
header('Location: ' . $url);
Multiple solutions to download...
Like a download button:
<a target="_blank" download="download" href="http://www.w3schools.com/css/trolltunga.jpg">Test</a>
You could also do a file_get_contents of the file in PHP and serve it with the appropriate headers like here:
But not quite via a redirect, unless the source contains the appropriate headers. There's always the button hack as shown here:
Any of these suit your needs?