使用JavaScript检查文件夹中是否存在文件

问题描述:

我要检查文件夹中是否存在文件.下面的代码是我尝试多次无法正常工作的时候.

I want to check a file exist in folder. Below code is while i'm trying to many times is not working.

<!DOCTYPE html>
<html>
<head>
<script>
function Start()
{
var path = "X:\ApplicationFiles\Journals\TandF\RJHR\Vol00000\180008\ML\IProof\TF-RJHR180008.xml";
if (File.Exists(path))
{
document.getElementById("Stage").innerHTML = "exists";
}
}
</script>
</head>
<body>
<table border="1">
<thead>
<tr><th>Job ID</th><th>JID</th><th>Article ID</th><th>Intrnl ID</th><th>Due Date</th><th>Current Status</th></tr>
</thead>
<tbody>
<tr><td>T76825</td><td>RJHR</td><td>1445583</td><td>180008</td><td>01-Mar-18</td><td><p id="Stage"/></td></tr>
</tbody>
</table>
</body>
</html>

这将不起作用,因为您的浏览器无法访问您的文件系统.

This wont work because your browser does not have access to your file system.

您可以从node.js服务器运行它

you can run this from a node.js server

请参见 https://en.wikipedia.org/wiki/JavaScript#Security