Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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

JavaScript
<!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>

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!
Posted

1 solution

You can't.
Javascript cannot access the local hard drive, by design.
Think about it: if you could, so could malicious sites...
 
Share this answer
 
Comments
Member 10535602 30-Jan-14 5:29am    
is it another solution using C# or something else?
by the way, I have to do this through a proxy server!
OriginalGriff 30-Jan-14 5:34am    
Not that works in 100% of cases: You can do it with an ActiveX control, but they only work with IE, and 99% of IE installations leave them at the default "disabled" setting for security reasons.
Server code is not supposed to access client hardware - or all our HDDs would belong to the a**holes of this world...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900