1

Suppose I have url of image like this : https://i.stack.imgur.com/Xdm6l.png

I want to use javascript and store this image to a give location in my local drive without any confirmations or download buttons. I want it to be saved silently.

I'm running javascript in console, not putting the script in the html page

I found a custom developed FileSaver.js, but have I have been unsuccessful in using it

https://github.com/eligrey/FileSaver.js

yashas123
  • 270
  • 5
  • 23
  • 2
    This is not possible from a browser. You could make a CLI program using node.js though. – Kao Nov 21 '17 at 11:31
  • I'm not putting the js in a html page, instead using it from console, And not possible even from this? github.com/eligrey/FileSaver.js – yashas123 Nov 21 '17 at 11:39

1 Answers1

1

Not possible in the browser.

If that were possible then any given website would have access to your local filesystem. That wouldnt be feasable.

As @Kao mentioned, it is however possible with javascript but you will need a different environment then the browser e.g. NodeJS or Electron etc.

ThatBrianDude
  • 2,952
  • 3
  • 16
  • 42
  • I'm running javascript in console, not putting the script in the html page, still not possible? – yashas123 Nov 21 '17 at 11:34
  • And not possible even from this? https://github.com/eligrey/FileSaver.js – yashas123 Nov 21 '17 at 11:37
  • Running JS in the browsers console is just as if it were part of the html page. You have the same API's and same permissions. FileSaver.js will definetly prompt the user with a window to save the file. You wont find anything that does it "undercover" – ThatBrianDude Nov 21 '17 at 12:28
  • Ok thank you, do know how can I convert the url to blob? – yashas123 Nov 21 '17 at 12:35
  • Sure: `let blob = new Blob(["your-url"], {type: 'file'})` https://stackoverflow.com/questions/34000412/how-do-i-convert-url-to-blob-with-javascript-or-jquery – ThatBrianDude Nov 21 '17 at 12:37