Web 应用程序访问用户的文件系统

Web application access user's file system

我正在为我的客户创建一个 Web 应用程序。该应用程序将安装在公司网络内的专用服务器上。 他想在网页上查看他的本地文件列表(来自他的本地 PC)。他的意思是任何访问者都可以从某个文件夹中看到他本地文件的列表。

我知道 Web 应用程序无法访问访问者的文件系统。浏览器通过设计限制了这一点。 当然,可能会有一些浏览器扩展、小程序和 Flash 应用程序,甚至黑客。但事实并非如此。

但是我该如何向他解释呢?他将我指向 'save as' 或 'load file' 对话框,并说其他应用程序可以做到这一点。不知道怎么跟他解释这只是浏览器的交互

我试图 google 获得一些证明的链接,但无法快速找到。

你们能给我一些描述无法从 Web 应用程序访问用户文件夹的文档的链接吗?

与客户端-服务器模型争论呢? 您向服务器发送请求(网站请求、文件或其他),网络服务器可以响应。 服务器(介于两者之间的网络服务器)上没有直接文件系统访问,客户端可以选择他发送到服务器的内容(浏览器中的文件选择器对话框)。

Mozilla. File System API Restrictions

Because the file system is sandboxed, a web app cannot access another app's files. You also cannot read or write files to an arbitrary folder (for example, My Pictures and My Documents) on the user's hard drive.

也许这份文件很棒?

http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#security-considerations

第 4.1 节

应用程序可以请求临时或持久存储space。临时存储可能更容易获得,由 UA 自行决定 [更宽松的配额限制,无需提示用户即可使用],但存储在那里的数据可能会在 UA 方便时删除,例如处理磁盘不足space.

相反,一旦持久存储被授予,在没有用户干预的情况下,应用程序存储在那里的数据不应被用户代理删除。应用程序当然可以随意删除它。在向应用程序授予持久存储 space 之前,UA 应该需要用户的许可。

此 API 指定文件系统上下文中的标准源隔离,以及跨调用的数据持久性。应用程序可能会使用临时存储进行缓存,如果它仍然存在于前一个会话中,它通常很有用。另一方面,如果您在下次调用时无法再次访问持久数据,那么它就毫无用处。然而,即使持久数据也可能被用户手动删除[通过 UA 或通过直接文件系统操作]。

最后整理了一些语录就完成了..

https://en.wikipedia.org/wiki/JavaScript#Security

scripts run in a sandbox in which they can only perform Web-related actions, not general-purpose programming tasks like creating files

https://www.us-cert.gov/publications/securing-your-web-browser

JavaScript, also known as ECMAScript, is a scripting language that is used to make websites more interactive. There are specifications in the JavaScript standard that restrict certain features such as accessing local files.

https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Introduction#restrictions

Because the file system is sandboxed, a web app cannot access another app's files. You also cannot read or write files to an arbitrary folder (for example, My Pictures and My Documents) on the user's hard drive.

下面的 html 允许我查看本地文件列表。

<!DOCTYPE html>
<html>
<body>

<p>Click on the "Choose File" button to upload a file:</p>

<form action="/action_page.php">
  <input type="file" id="myFile" name="filename">
  <input type="submit">
</form>

</body>
</html>