I am trying to force download pdf instead of opening. I have used
<a href='path' download>
but its still open file in mobile devices like iphone I need to force to download file instead of open Thanks in advance
Advertisement
Answer
Im giving you a idea for force downloading through php,
Create a PHP file download.php, change accordingly to your php app.
JavaScript
x
<?php
// Ajmal Praveen
$file_name = 'file.pdf';
$file_url = 'http://yoururl.com/' . $file_name;
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename="".$file_name.""");
readfile($file_url);
exit;
?>
Make a link
JavaScript
<a href="./download.php?file=file.pdf" download>Download</a>