0

Good Morning,

I would like to know how to do in HTML to type the folowing url of a file in a browser:

http://localhost:7000/pictures/picture01.png

And to automatically download it

I do not want to create a link like that:

<a href="picture01.png">download my picture</a>

Is that possible?

2 Answers2

0

The browser will not download the picture automatically for you, the address bar will just use the URL provided, and do the DNS lookup and render/download the data/image/html in the client machine from the server.

And for this reason, only we have clientside scripting language to tell what to do with the downloaded contents. Now to download the image automatically what you can do is download a javascript file that will execute in the client machine and download the image automatically.

just trigger the download on javascript/jquery onLoad event

refer this for more info: Force Download an Image Using Javascript

smali
  • 4,687
  • 7
  • 38
  • 60
0

If I understand your question right, you want GET to a certain URL to trigger the download of an asset.

Yes, it's possible. To achieve this you need to configure your server to respond with octet stream. This way, the browser will show download window automatically.

You can find more details & some discussion here.

Igor Bykov
  • 2,532
  • 3
  • 11
  • 19