0

Is there is any way to download files from server to local folder without any dialog window?

My code

function SaveToDisk(fileURL, fileName) {
    // for non-IE
    if (!window.ActiveXObject) {
        var save = document.createElement('a');
        save.href = fileURL;
        save.target = '_blank';
        save.download = fileName || 'unknown';

        var event = document.createEvent('Event');
        event.initEvent('click', true, true);
        save.dispatchEvent(event);
        (window.URL || window.webkitURL).revokeObjectURL(save.href);
    }

    // for IE
    else if ( !! window.ActiveXObject && document.execCommand)     {
        var _window = window.open(fileURL, '_blank');
        _window.document.close();
        _window.document.execCommand('SaveAs', true, fileName || fileURL)
        _window.close();
    }
}

This is my code this will open a dialog window Please tell me is there is any way to silent download?

Richardson. M
  • 852
  • 2
  • 17
  • 28
  • In short, you can't. This creates a grave security risk: imagine an attacker that infiltrated Google and forces you to download a Trojan horse silently in the background? – Terry May 05 '16 at 05:56
  • Possible duplicate of [Force download through js or query](http://stackoverflow.com/questions/5192917/force-download-through-js-or-query) – Terry May 05 '16 at 05:56
  • Thank you Terry, You saved my time. – Richardson. M May 05 '16 at 06:51

0 Answers0