How to make by clicking on the link to download pictures?

How to make by clicking on the link to download pictures?
March 12th 20 at 08:40
3 answers
March 12th 20 at 08:42
Then quietly and without js you can do
<a href="images/img.jpg" download>Download image</a>
I understand a person need behavior as here
https://www.iconfinder.com/icons/315531/eyebrows_f... - stuart commented on March 12th 20 at 08:45
I gave the simplest solution. The question does not specify how it should be downloading. - peyton4 commented on March 12th 20 at 08:48
@stuart, here, another not particularly like, clicked and downloaded. - Mortimer96 commented on March 12th 20 at 08:51
href="images/img.jpg" - will open in the browser on the blank page. then you need to press ctrl+s.
href="files/doc.pdf" - before asking what to do, now usually open in the browser immediately.

Force downloading a file in download folder can as I described above. - stuart commented on March 12th 20 at 08:54
@peyton4, wait for the author of the question. Am I reading between the words :) - stuart commented on March 12th 20 at 08:57
If using javascript, then you can. But IMHO namuchaetes with the bytes that have no character representation
function download(content, filename, contentType)
{
 if(!contentType) contentType = 'application/octet-stream';
 var a = document.createElement('a');
 var blob = new Blob([content], {'type':contentType});
 a.href = window.URL.createObjectURL(blob);
 a.download = filename;
a.click();
}
- stuart commented on March 12th 20 at 09:00
March 12th 20 at 08:44
load the image to the server. then the link

<a href="site.ru/img.jpg">Download</a>
March 12th 20 at 08:46
below image is downloaded, not opened in browser
need on the server to give it with mediatayp on the similarity of the binary data
application/octet-stream

ie need an intermediary such as a php script
or to solve the problem push installation media type in the nginx configuration . - stuart commented on March 12th 20 at 08:49

Find more questions by tags jQueryJavaScript