Downloading a file

Hi!

Is there any way to download a file from http to the computer without using too much crazy activex

System.Shell.Folder.copyHere("http:// ....") does not work. I need to download a picture, since there is no "Save picture as..." in gadget's context menu.

Thanks for any idea



Answer this question

Downloading a file

  • jellali

    Use an ADO binary stream to read it, then write the stream to a file. See this thread.



  • rcurrie

    On second thoughts, that's not going to work. You'll need to read the image via an XML request, but that has a limit on the amount of data you can read, so that will probably fail too:

    var xmlReq;

    function loadImage(url) {

    xmlReq = new XMLHttpRequest();
    xmlReq.onreadystatechange = imageCheck;
    xmlReq.open("GET", url, true);
    xmlReq.send(null);
    }

    function imageCheck() {
    if(xmlReq.readyState < 4) return;

    if(xmlReq.status == 200) {
    // image may be in xmlReq.responseText;
    }

    xmlReq.abort();
    }


    ActiveX is probably going to be your only solution, unfortunately.

  • Blast

    Things are getting complicated a bit...but okay, I'll try. Do you have any idea what the limit is

    However, since I don't expect the file to exceed 100kB I guess it should work well.


  • Fox Me Up

    Thanks, that seems suitable.

    It would be much easier if I could get the Shell.Item object for the URI, though (if you look for suggestions for future versions )


  • yabing

    Hi again...

    I cannot make it working... how should I load the file If I use stream.Open("http...") I get argument error and if I use stram.LoadFromFile("http...") I get file could not be opened...


  • Downloading a file