0

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.

JAM
  • 6,045
  • 1
  • 32
  • 48
  • Well guess what, it is not possible. Local file access is very limited because it is scary. – epascarello Dec 14 '18 at 20:27
  • I know it is scary. This is an internal website that maybe 7 people might use. The files are on a PC on the network. Files are not on the PC where the user opens my webpage. The people don't want to remember the complicated network folder paths or spent minutes trying to find the right folder. Trying to make life easier with my site. I am willing to do whatever necessary. Make an FTP server? I only need to be point to the right direction. How do I setup Django to serve files to my front end to open a folder? – YouGotA.BigEgo Dec 14 '18 at 20:34

1 Answers1

0

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.

kev
  • 1,011
  • 8
  • 15
  • Can you kindly show me an example of this kindof setup. I am willing to do whatever necessary. The few people who is going to use this web page/site do not want to remember the complicated network paths. They just want to open the folder (to see the files). – YouGotA.BigEgo Dec 14 '18 at 20:37
  • You made an important suggestion above. Run on server side and transmit to the browser. Did you mean transmit the virtual directory path? Doesn't that still look like a path network path to my JS client side script to open? – YouGotA.BigEgo Dec 14 '18 at 20:43
  • What type of webserver do you have? – kev Dec 14 '18 at 20:43
  • I have currently my Django development server on the PC where I am developing. Once site development is complete, I have to move everything to a production server. Apache server for web front end + mod_wsgi to talk to Django back end server. To keep it short, I have a Django server since you said by server side has to do everything anyway. Im on Django 2.1 – YouGotA.BigEgo Dec 14 '18 at 20:56
  • In my settings file I add a setting called something like: VIRTUAL_DIRECTORY = "my_network_directory/" – YouGotA.BigEgo Dec 14 '18 at 22:16