使用 Javascript 或 jQuery 进行文件操作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5770645/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 18:17:24  来源:igfitidea点击:

File operation using Javascript or jQuery

javascriptjqueryfile

提问by thecodeparadox

I want to make some file operation using Javascript or jQuery like:

我想使用 Javascript 或 jQuery 进行一些文件操作,例如:

  1. File create
  2. File write
  3. File read
  4. Update
  5. Remove/delete
  1. 文件创建
  2. 文件写入
  3. 文件读取
  4. 更新
  5. 移除/删除

Is it possible to do above stuffs? If possible, from where I can get the idea? Please suggest me.In any end (client/server) how can it be done?i asked this just for know!

可以做以上的事情吗?如果可能的话,我从哪里可以得到这个想法?请建议我。无论如何(客户端/服务器)怎么做?我问这个只是为了知道!

回答by Quentin

In any end (client/server)

在任何一端(客户端/服务器)

You weren't specific about which server side JS implementation you are using, so for Node.js:

您没有具体说明您使用的是哪个服务器端 JS 实现,因此对于 Node.js:

See the file system sectionof the Node.js documentation

请参阅Node.js 文档的文件系统部分

回答by Raynos

There are 2 HTML5 APIs of interest.

有 2 个感兴趣的 HTML5 API。

The File APIwhich allows you to read files (of a users choice). Most modern browsers implement this.

允许您读取文件(用户选择)的文件 API。大多数现代浏览器都实现了这一点。

The File Write APIwhich allows you to write to files. No browsers implement this as of now.

允许您写入文件的文件写入 API。目前还没有浏览器实现这一点。

I presume you can also use IE only ActiveXcontrols to do file manipulation on windows.

我想你也可以使用 IE only ActiveX控件在 Windows 上进行文件操作。

回答by Hemant Sakta

As I can understand from your question you are trying to do file operation at client end. If you are using IE and windows operating system, you can do that using FileSystemObject. This doesn't work for other browser and other operating systems as FileSystemObject is ActivexObject given by Windows. For details refer http://www.codeproject.com/KB/scripting/JavaScript__File_Handling.aspx

正如我从您的问题中了解到的,您正在尝试在客户端进行文件操作。如果您使用的是 IE 和 windows 操作系统,则可以使用 FileSystemObject 来实现。这不适用于其他浏览器和其他操作系统,因为 FileSystemObject 是 Windows 提供的 ActivexObject。有关详细信息,请参阅http://www.codeproject.com/KB/scripting/JavaScript__File_Handling.aspx