简体   繁体   English

如何检查文件在JavaScript中是否本地存在?

[英]How to check if file exists locally in JavaScript?

I'm writing a plugin for some tool and the API is JavaScript. 我正在为某些工具编写插件,API是JavaScript。 I need to know whether a file exists or not, and I'd like to avoid operating system calls in order to abstract from it, but using the JavaScript language instead, if possible. 我需要知道一个文件是否存在,并且我想避免操作系统调用以便从中提取文件,但是如果可能的话,请改用JavaScript语言。

Is it possible to know if a file exists locally in JavaScript, given a path? 给定路径,是否可以知道JavaScript中本地是否存在文件?

JavaScript has no native file handling functions whatsoever. JavaScript没有任何本机文件处理功能。 Any access to the file system needs to be via an API provided by the host environment. 对文件系统的任何访问都需要通过主机环境提供的API进行。

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

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