2

I want to create a email body that contains download link, when someone click on the download link, it will be immediately download.

But instead the following code open the image in new tab from the browser. How to solve this problem?

$message .= '<a download href="ip-address/img/feature-4.png">Download 
Link</a>';**strong text**

p/s:I had tried force browser to download image files on click ,but it did not solve my problem.

Community
  • 1
  • 1
  • Possible duplicate of [How can I force an Image download in the browser?](http://stackoverflow.com/questions/11090272/how-can-i-force-an-image-download-in-the-browser) – M. Eriksson May 10 '17 at 06:22
  • yep, check this out as well http://stackoverflow.com/questions/17527713/force-browser-to-download-image-files-on-click#answer-17527821 – tiomno May 10 '17 at 06:23
  • i had tried the suggested solution, but doesn't seems to be working. – Kimkim900109 May 10 '17 at 06:50
  • _"I had tried the suggested solution"_, show us what you tried (add it to your current question) and explain what _"doesn't seems to be working"_ means. Did it still just showed the image in the browser? Did you get any error messages? – M. Eriksson May 10 '17 at 07:35
  • @ Oh, yes, My bar, I'm gong To remove The comment – il_raffa May 10 '17 at 07:38
  • @MagnusEriksson Oh yes My badante, I'm gong To remove It. – il_raffa May 10 '17 at 07:40

1 Answers1

0

Add download attribute to link, but this solution works in modern browsers only.

<a href="/path/to/image" download="myimage"><img src="/path/to/image" /></a>
gobliggg
  • 237
  • 2
  • 13
  • IE doesn't support it (which unfortunately is a common browser) and firefox only support it for same origin. Another issue is that the link is in an email. I doubt that email clients (except from web mail clients) support that attribute. – M. Eriksson May 10 '17 at 06:39
  • @Imam I tried your solution, it doesn't seems to be working. – Kimkim900109 May 10 '17 at 06:53