Jump to content

Run download script after x seconds and show message.


alessiaass

Recommended Posts

I have this script in my website http://www.zubrag.com/scripts/download.php and this code in .htaccess 

RewriteEngine On
# you can add whatever extensions you want routed to your php script
RewriteCond %{REQUEST_URI} \.(doc|rar|zip|pdf)$ [NC]
RewriteRule ^(.*)$ download.php?f=$1/ [L]

I want users to wait 3 seconds before running script and I want them to see this message while waiting "Thanks for downloading".

Users will click on www.mysite.com/download.php?f=downloadfile.zip

You need a separate page that shows the message and has the delay. Ever seen one of those "your download should start in X seconds, click here if it does not" pages? That.

<html>
<head>
<meta http-equiv="Refresh" content="3;url=http://www.example.com/download.php?f=downloadfile.zip">
</head>

<body>
<p><a href="http://www.example.com/download.php?f=downloadfile.zip">Download</a><p>
</body>
</html>
If the page were more complicated than that, it would take the average user at least a couple seconds to even find where the link is. (The first time.) If you don't want them to even see the link then you can hide it with CSS and do some simple Javascript work to show it.

window.setTimeout(function() {
    // show the link
}, 3000);

Exactly like those pages, but users will be redirected with htaccess  (code above) and if it could be sth like:

wait file: wait.php?f=download.zip (where wait.php will search in subdirectories)

and after x seconds wait.php?=download.zip redirects to download link/page which may be download.php?f=download.zip or site.com/downlaods/lol/words/download.zip

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.