Mail is sent via php (main()) , in the message text there is a link of the following type:

 <a href="$url/filename.txt">скачать</a> 

That is, a direct link to the file, when you click, you need to download the file, and not open it in the browser. Headers can not pass.

  • And send the file along with the letter? - Dmitriy Simushev
  • The file can be large, and so that there is no crap, the file is on our server. - aat
  • If you insert a link, it will in any case be opened by the browser - Dmitriy Simushev

2 answers 2

For html

 <a href="/images/myw3schoolsimage.jpg" download> 

You can use the copy function for php if you need to do it internally on the server

 <?php $url='http://someserver21973892798/file.html'; if(!copy($url,__DIR__.'/newfile.html')){ echo "не удалось скопировать ...\n"; } 

/newfile.html sure to specify the name of the new file /newfile.html (for example) and recommend using the absolute path that we get with the magic constant __DIR__ . In $url use your path to the file you want to upload to your server.

    Try adding download parameter to the link:

     <a href="file.pdf" download>скачать</a> 

    You can specify the name of the saved file:

     <a href="file.pdf" download="filename">скачать</a> 

    But it does not work in all browsers.