简体   繁体   中英

How to can i open a network path in file explorer to view files using javascript?

I asked this before, and I am told that this is impossible. It this true?

All I want is to open a network folder when I click a button. To open 'File Explorer' to that network path on the PC. Or on the browser. I prefixed file:/// to the path so that it may open in a browser.

//jQuery for button 1.
$(document).on("click",".Button1",function (){
    var log1 = "file:/"+this.value;
    //  this.value has path like this: ///PCname/Foldername/subfolder
    window.location.href = log1
}); 

Am I asking the impossible? I can't copy my files to document root. I have 10s of thousands of files. This is why I want to open a folder on my Windows PC to that path. My path to files changes depending on what the user has selected, and my files are 50MB or less.

Is there a way I could open a network folder in the browser like this (not local drive, network path), OR a way to open a folder on the PC to that network path when I click a button?

My backend is Django+Python.

JavaScript in the context you mention, can't do that. In this context JS is a client side programming language that runs in the browser.

What you have in mind needs to run on the server-side and then transmitted to the browser.

Here are the general steps you should take:

  1. Configure a virtual directory in your webserver that point to the directory you have on hour drive so that a specific URL point to that location on your drive.
  2. Enable directory listing in your webserver so that the webserver automatically list all the files and folders available.

This is the most basic setup. You can improve that with server-side technologies like Python or NodeJS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM