0

How to return file to user contact form php+ajax on my site?

mail($to,$email_subject,$email_body,$headers);
return readfile(polychor_file.pdf);    
anuarthor
  • 23
  • 1
  • 1
  • 7

2 Answers2

0

Did you asking about Send Email with Attachment? If yes, then here is a source on how to "Send Email with Attachment" : https://www.codexworld.com/send-email-with-attachment-php/.

Makdia Hussain
  • 744
  • 3
  • 11
0

If you want to file return :

    $attachment_location = "usaflag.gif";

    if (file_exists($attachment_location)) {

        header("Content-Description: File Transfer");
        header("Cache-Control: public"); 
        header("Content-Type: application/octet-stream'");
        header("Content-Transfer-Encoding: Binary");
        header("Content-Length:".filesize($attachment_location));
        header("Content-Disposition: attachment; filename=usaflag.gif");
        readfile($attachment_location);
        die();        
    } else {
        die("Error: File not found.");
    }