Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript automatic pdf download Reply To: automatic pdf download

#250856
chauhanheena
Participant

Hi @shikkediel

I tried the above too. but don’t work and looks like I’m no were near getting a solution to this.

I finally tried this but till not there.

in the sendmail.php , I/m trying to call another php file (download.php) which starts the download.

if(mail($address, $e_subject, $msg, $headers)) {
    header( "Refresh:5; url=download.php");
    echo "<fieldset>";
    echo "
"; echo "Thank you! $fname. PDF download will automatically start right now."; echo "
"; echo "</fieldset>"; } else { echo 'ERROR!'; }

download.php

<?php
header("Content-type:application/pdf");

// Use the name of the pdf file that is saved as… Can be different from the file on the server
header("Content-Disposition:attachment;filename=sample.pdf");

// The PDF file name on the erver
readfile("sample.pdf");
?>

when i run the download.php int eh browser, the pdf downloads, but via sendmail.php, does not. anyhow the mail is sent.
any suggestions on this

thanks!