简体   繁体   English

如何在File Explorer中打开网络路径以使用javascript查看文件?

[英]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. 在PC上打开“文件资源管理器”到该网络路径。 Or on the browser. 或在浏览器上。 I prefixed file:/// to the path so that it may open in a browser. 我在该路径前添加了file:///前缀,以便可以在浏览器中打开它。

//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. 这就是为什么我要在Windows PC上打开指向该路径的文件夹的原因。 My path to files changes depending on what the user has selected, and my files are 50MB or less. 我的文件路径会根据用户选择的内容而变化,并且我的文件为50MB或更小。

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? 有没有一种方法,我可以在浏览器中打开一个网络文件夹像这样 (没有本地驱动器,网络路径),还是有办法打开PC到网络路径上的文件夹,当我点击一个按钮?

My backend is Django+Python. 我的后端是Django + Python。

JavaScript in the context you mention, can't do that. 您提到的上下文中的JavaScript无法做到这一点。 In this context JS is a client side programming language that runs in the browser. 在这种情况下,JS是在浏览器中运行的客户端编程语言。

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. 在Web服务器中配置一个虚拟目录,该目录指向小时驱动器上的目录,以便特定的URL指向驱动器上的该位置。
  2. Enable directory listing in your webserver so that the webserver automatically list all the files and folders available. 在Web服务器中启用目录列表,以便Web服务器自动列出所有可用的文件和文件夹。

This is the most basic setup. 这是最基本的设置。 You can improve that with server-side technologies like Python or NodeJS. 您可以使用Python或NodeJS之类的服务器端技术进行改进。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 HTML / JS 打开我的文件资源管理器 - How Can I Open My File explorer using HTML / JS 如何打开可以在资源管理器中选择多个文件的文件选择器 - how to open file chooser that can choose multiple files in Explorer 如何从Javascript打开Windows资源管理器窗口? - How can I open a Windows Explorer window from Javascript? 如何使用 JavaScript 获取文件和文件名? - How can I get files and file names using JavaScript? javaScript 中是否有任何方法可以在客户端默认文件资源管理器中打开一个文件夹 - Is there any way in javaScript through that I can open a folder on the client default file explorer 使用 JavaScript 打开资源管理器输入文件 - Open explorer input file with JavaScript 如何显示链接-ike 文本以打开资源管理器以上传文件/文件夹? - How can I show a link-ike text to open the Explorer to upload files/folders? 如何使用 reactjs 或 javascript 使用文件路径读取 excel 文件中的数据 - How can I read the data in the excel file with reactjs or javascript using the path to the file 如何有效地将网络流缓冲到JavaScript中的文件? - How can I efficiently buffer a network stream to a file in javascript? 给定文件路径,使用HTML / Javascript在File Explorer(Windows)或Finder(Mac)中打开 - Given File Path, Open in File Explorer (Windows) or Finder (Mac) with HTML/Javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM