I have a file, named download.php
, which contains a file to be downloaded, so it has the following headers (declared with PHP):
header("Content-Type: ".pathinfo($_GET['file'], PATHINFO_EXTENSION));
header("Content-Length: ". filesize($_GET['file']));
header("Content-Disposition: attachment; filename=". $_GET['file']);
download.php
is opened as a popup with jQuery by an other page.
Now I want download.php
to self-close (using JavaScript) after some seconds (so I'm secure that download started) but I didn't manage to write working code.
Here are the codes I tried (I placed them after headers):
window.setTimeout('self.close();', 3000);
window.setTimeout('function(){self.close();}', 3000);
window.setTimeout(self.close();, 3000);
I also tried simply:
self.close();
but it does not work anyway.
I tried to put these codes both in <head>
and in <body>
.
What could be the problem?