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

Edited by alessiaass
Link to comment
Share on other sites

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);
Link to comment
Share on other sites

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

Edited by alessiaass
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.