download attribute of html is not working for iphone browser



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

Answer

Im giving you a idea for force downloading through php,

Create a PHP file download.php, change accordingly to your php app.

    <?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

<a href="./download.php?file=file.pdf" download>Download</a>


Source: stackoverflow