0

How to make the Save as Dialog box in html design help with Javascript.

I have one img tag and I would like to save the image to local drive via button click.

Thanks

Maninblack
  • 743
  • 1
  • 8
  • 17

1 Answers1

1

See this fiddle

You can use

<a href="your_image.jpg" download="/path/to/image">  Download This Image</a>  

eg:

<a href="myimage.jpg" download="images/gallery/1.jpg">Download This Image</a>
Lal
  • 14,726
  • 4
  • 45
  • 70
  • This attribute is not supported in IE. You can see if the support is enough for your case: http://caniuse.com/#feat=download – Sampsa Jan 03 '15 at 17:58
  • in that case i think its difficult to do just with javascript..we should try a server-side scripting language like php.. – Lal Jan 03 '15 at 18:01
  • @Lal Really appreciate your help. I am using the Chrome. I would like to save the image to local drive by choosing the folder form the dialog box. you just right click on the image and choose save as image. one dialog box will show right. thats what am expecting when click the button. – Maninblack Jan 03 '15 at 18:03
  • please check this-http://prntscr.com/5o1t7i – Maninblack Jan 03 '15 at 18:05
  • isnt that the same dialog box that pops up..check my fiddle once more.. – Lal Jan 03 '15 at 18:05
  • Hey @Maninblack ...did you get it??? – Lal Jan 03 '15 at 18:13
  • @Lal I think your dialog pops out only if you don't have the default download directory in your browser.. Because I can't see it as well – m_pro_m Jan 03 '15 at 18:51
  • OMG its working well for me..in chrome..in which are you testing @m_pro_m ??? – Lal Jan 03 '15 at 18:52
  • But from my side, the image download when click the download button. – Maninblack Jan 03 '15 at 19:23
  • You too testing in chrome???i think these are broeser settings..in firefox it just downloads to the default downloads folder..i dont think that can be changed – Lal Jan 03 '15 at 19:25
  • am testing in chrome. – Maninblack Jan 03 '15 at 19:28
  • See this [link](https://github.com/kaepora/miniLock/issues/174)..it addresses that issue.. – Lal Jan 03 '15 at 19:29
  • i just disable the default download in chrome and firefox. not it is asked to save to location :), – Maninblack Jan 03 '15 at 19:32