检查我的硬盘中是否存在该文件 [英] Check if the file exist in my hard drive
问题描述
我正在尝试从服务器下载一些PDF文件。没有文件的直接地址,所以我必须启动一个网址,然后创建一个临时链接,浏览器开始下载它与下载管理器。
我已经使用此代码延迟打开网址
I'm trying to download some PDF files from a server. there is no direct address for files, so I have to launch a url, then a temporary link will create and browser start to download it with a download manager.
I already used this code to open urls with delay
<!doctype html>
<html>
<head>
<title>Open Windows</title>
<script>
function openWindow(){
var x = document.getElementById('a').value.split('\n');
atTime = 0;
for (var i = 0; i < x.length; i++) {
if (x[i].indexOf('.') > 0) {
site = x[i];
if (x[i].indexOf('://') < 0) { site = 'http://' + x[i]; }
setTimeout("window.open('" + site + "')", atTime);
atTime += 20000;
}
}
}
</script>
<style>
html, body
{
height : 99%;
width : 99%;
}
textarea
{
height : 80%;
width : 90%;
}
</style>
</head>
<body>
<textarea id="a"></textarea>
<br>
<input type="button" value="Open Windows" onClick="openWindow()">
<input type="button" value="Clear" onClick="document.getElementById('a').value=''">
</body>
</html>
这是我的问题:
我如何自定义此代码以获取一些网址,在浏览器中打开它们(开始下载),然后检查文件是否已下载(存在)在我的硬盘驱动器上的路径(D:\downloads),启动另一行打开。
这是一个url的例子
http://www.example.com/download.php?token=87345& pid = 12345
这是文件名:12345.pdf
提前致谢!
here is my question:
How can I customize this code to get some urls, open them in the browser (an starting a download), then check if the file downloaded (exist) in a path on my hard drive (D:\downloads), start the other line to open.
this is an example of url
http://www.example.com/download.php?token=87345&pid=12345
and this is the file name : 12345.pdf
Thanks in advance!
推荐答案
你不能。
Javascript无法通过设计访问本地硬盘。
想想看它:如果可以,恶意网站也可以......
You can't.
Javascript cannot access the local hard drive, by design.
Think about it: if you could, so could malicious sites...
这篇关于检查我的硬盘中是否存在该文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!