How to download a local file that is on Another Local disk with pure Javascript

0

I have the following code:

<button onclick="javascript:descargarZip(this.value)" value="<%=sArchivoZip%>"><img src="./IMG/icons/mail-arrow-down-icon.png" /></button>

which calls a download function in js:

function descargarZip(val)  

{

 var url='file://G://Pibexpress//logipc//'+ val;
  // location.href= url;

 window.open(url, 'Download');

}

* The problem is that the file is NOT inside the IIS (C: //inetpub//Wwwroot/pagina/pagina.asp) where the asp is located; but it is in another unit as an example: G: //folder/archives/archive.zip.

The browser tells me this.

FIREFOX Error: Access to 'file: /// G: //folder//archives//archive.zip' from script denied

CHROME Not allowed to load local resource: file: /// G: //folder//archives//archive.zip '.

And therefore I can not download the file, if anyone knows the solution I would appreciate it very much.

THANK YOU FOR YOUR SUPPORT =)

    
asked by Rodrigo Leonardo Muñoz Torres 06.09.2018 в 03:16
source

1 answer

1

The following happens, JavaScript is executed next to the client / browser, when you tell it to try to download that file it will search it on the computer where it is running. What you can do is configure the file or folder where the file is located in the IIS so that it can be accessed and directed by http. (By the way, it must be the same domain or it will give you CORS problems). A second is that you program something next to the server with C # or vb (example) that reads and displays the file.

    
answered by 06.09.2018 в 05:58