alessiaass Posted March 9, 2015 Share Posted March 9, 2015 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 Link to comment https://forums.phpfreaks.com/topic/295196-run-download-script-after-x-seconds-and-show-message/ Share on other sites More sharing options...
requinix Posted March 9, 2015 Share Posted March 9, 2015 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 https://forums.phpfreaks.com/topic/295196-run-download-script-after-x-seconds-and-show-message/#findComment-1507955 Share on other sites More sharing options...
alessiaass Posted March 9, 2015 Author Share Posted March 9, 2015 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 Link to comment https://forums.phpfreaks.com/topic/295196-run-download-script-after-x-seconds-and-show-message/#findComment-1507957 Share on other sites More sharing options...
requinix Posted March 9, 2015 Share Posted March 9, 2015 And I'm saying, Don't make the download script itself do the waiting. Make whatever page that shows the link, or whatever, do the wait. Link to comment https://forums.phpfreaks.com/topic/295196-run-download-script-after-x-seconds-and-show-message/#findComment-1507968 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.