Force download images from Google Chrome without opening a new tab

We want to allow the user to upload a picture using the button from our website. We have a basic boot that works fine (it saves it to disk), but we do this by opening a new window ...

window.open('mypicture', '_blank');

Unfortunately, this creates a new tab in Chrome that does not disappear. We do not have the most sophisticated users, and they can get confused if the screen suddenly disappears.

We tried this with ...

location.href='mypicture'

This works fine in IE, but in Chrome it completely ignores the download.

Is there any other way to force an image to load without opening a new window?

+3
source share
2 answers

, Chrome (FF )? , .

<a href="mypicture">Download</a>
0

http-, ,

Content-Disposition: attachment; filename="downloaded.jpg"

.., PHP script ( - ), .

+2

Source: https://habr.com/ru/post/1762971/


All Articles