Shoutbox

Download image from URL and save locally - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Download image from URL and save locally (/showthread.php?tid=69172)

Download image from URL and save locally by ketchup_blade on 12-05-2006 at 01:39 PM

Hello,

for my script, I need to be able to save locally an image that is available at a specific URL, for example: http://shoutbox.menthix.net/images/smilies/xso_wink.gif

I'm not used to scripting with Jscript, and i can't find a way to download and save this binary file locally.

Any tips?

kb


RE: Download image from URL and save locally by andrewdodd13 on 12-05-2006 at 04:14 PM

You can use the following:

var dlURL = "http://shoutbox.menthix.net/images/smilies/xso_wink.gif";
var localfile = FSO.BuildPath("<PATH TO SAVED LOCATION>");
var ret = Interop.Call('urlmon', 'URLDownloadToFileW', 0, dlURL, localfile, 0, 0);


RE: Download image from URL and save locally by John Anderton on 12-05-2006 at 04:17 PM

I don't know if i should save this but imo there isn't any practical use to this script. If you know the url why not open it in your browser and save it? :-/
Or if you want to save wallpapers, use a program like Download Accelerator Plus (DAP) that allows addition of links to download queue.
That's just my 2 cents :)


RE: Download image from URL and save locally by Felu on 12-05-2006 at 04:32 PM

quote:
Originally posted by andrewdodd13
var dlURL = "http://shoutbox.menthix.net/images/smilies/xso_wink.gif";
var localfile = FSO.BuildPath("<PATH TO SAVED LOCATION>");
var ret = Interop.Call('urlmon', 'URLDownloadToFileW', 0, dlURL, localfile, 0, 0);
You forgot to declare FSO [Image: msn_tongue.gif]
code:
var FSO = new ActiveXObject('Scripting.FileSystemObject');
quote:
Originally posted by John Anderton
I don't know if i should save this but imo there isn't any practical use to this script. If you know the url why not open it in your browser and save it?
With a script [Image: xso_undecided.gif]. This might be used for downloading Script Updates etc. Though downloading a image is not needed :P.
RE: RE: Download image from URL and save locally by andrewdodd13 on 12-05-2006 at 04:51 PM

quote:
Originally posted by -!Felu!-
quote:
Originally posted by andrewdodd13
var dlURL = "http://shoutbox.menthix.net/images/smilies/xso_wink.gif";
var localfile = FSO.BuildPath("<PATH TO SAVED LOCATION>");
var ret = Interop.Call('urlmon', 'URLDownloadToFileW', 0, dlURL, localfile, 0, 0);
You forgot to declare FSO [Image: msn_tongue.gif]
code:
var FSO = new ActiveXObject('Scripting.FileSystemObject');

Oops, that was silly! I just copied some code I'd already used and modified it slightly, should've checked it :|
RE: Download image from URL and save locally by Spunky on 12-05-2006 at 05:07 PM

quote:
Originally posted by John Anderton
If you know the url why not open it in your browser and save it?

This could be useful if someone send you a link to an image... (just check start and end of the link for certain text such as .png and so on). You can then download it without having to open a browser or DAP (which both open wuite slow in comparison to just saving it directly and then possibly opening it in a default app such as "Windows Fax and Picture Viewer"
RE: Download image from URL and save locally by John Anderton on 12-05-2006 at 07:21 PM

quote:
Originally posted by -!Felu!-
Though downloading a image is not needed
quote:
Originally posted by ketchup_blade's thread title
Download image from URL and save locally
Any other questions? :P

quote:
Originally posted by SpunkyLoveMuff
You can then download it without having to open a browser
Ok. There is clicking a link and seeing it in the browser and deciding if you want to save it and letting a script download the image to a location and open in with windows fax and picture viewer, deciding to keep it or not and then either deleting it or moving it to the appropriate storage place (for people like me to keep different types of wallpapers/images in different folders)
Some how, the earlier seems lesser work to me. And opening a browser, looking and saving would be quicker than the other method :P
RE: RE: Download image from URL and save locally by ketchup_blade on 12-05-2006 at 08:38 PM

quote:
Originally posted by John Anderton
I don't know if i should save this but imo there isn't any practical use to this script. If you know the url why not open it in your browser and save it? :-/


Yes there is.  Actually, you can't assign the Messenger.MyDisplayPicture property with an image URL (unlike when you select your image manually within Messenger).  So if I want to dynamically use an image from the Web, I need to first save it on the disk.

Thanks all for the code, it works!  I thought that the FSO didn't work with binary files...

kb