0

I want to, once the user has arrived the page, first, download an item using another script and then, redirect him or her to the index.

So I have the following code:

$filename = $_GET["file"];

$down = 'components/com_djclassifieds/views/item/tmpl/download.php?file='.$filename;

header( "refresh:2;url=$down" );   

header( "refresh:5;url=index.php" );

And, for example, the following url:

http://my.web.com/index.php?option=com_k2&view=item&layout=item&id=39&file=test.pdf

But it is not working. I also tried to use 'Location' in this code:

$filename = $_GET["file"];

header('Location: http://'.$_SERVER['HTTP_HOST'].str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']).'/components/com_djclassifieds/views/item/tmpl/download.php?file='.$filename);

exit;

header( "refresh:5;url=index.php" );

And it downloads the file but after that it does not redirect me to the index.

What am I doing wrong?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Zariweya
  • 295
  • 3
  • 13

1 Answers1

-1

Don't bother with the PHP. You can do it with JQuery.

HTML:

<script src="code.jquery.com/jquery.min.js"></script>
<div style='display:none;' id="div"></div>
<script>
var iframe = $("<iframe/>").attr({
    src: "http://example.com/path/file.extension"
}).appendTo($("#div"));
window.location="http://example.com/path/redirect.html"
</script>
Scelesto
  • 775
  • 6
  • 13