Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Location
    China
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question PHP script to start download after specific time

    I am working on file hosting project like Hotfile. I have faced a very big problem that is I do not know how to start download after given specific time. I know how to do this with Java Script but my client do not accept that

    please help me on this matter

    Thank you in advance
    Last edited by ShaneC; 04-21-2012 at 02:34 AM. Reason: Marked resolved

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,324
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    Quote Originally Posted by Asela View Post
    I do not know how to start download after given specific time.
    Can you clarify this a bit?

    Do you want the client to connect but not receive any file data until a certain time? (EG there is a connection but nothing is sent)

    Do you want to initiate a download at a certain time? (Not possible - html is stateless so the client would need to keep re-trying)

    Do you just want the link to the download to be available only at a certain time? (Easy but users can still use a direct link)
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • Users who have thanked tangoforce for this post:

    Asela (04-21-2012)

  • #3
    Codeasaurus Rex
    Join Date
    Jun 2008
    Location
    Redmond, WA
    Posts
    659
    Thanks
    31
    Thanked 100 Times in 94 Posts
    So it sounds to me that you want to have a user visit a page and then, after a brief countdown, the file begins download. Is this correct?

    If so the most practical method really is JavaScript. I would recommend having a chat with your client and informing them that to do a workaround would be less efficient, take more work, and be more costly.

    Otherwise, there are some workarounds you can use.

    PHP with IFRAMES: This would be a super hacked approach in my opinion. Have your normal download page. Then have an IFRAME on that page which uses PHP's sleep function:

    Code:
    sleep( 5 ); // Sleeps for 5 seconds
    Then, after your page loads, the IFRAME will load your download page. The download page will take 5 seconds to load, and then show whatever content you desire.

    Flash: Have a flash client execute the download. Flash can, using ActionScript, delay the download. Having said this, I really wouldn't recommend a download site that depends on Adobe Flash.

    Again, JavaScript is the way to go. Barring that, the PHP option. Please let me know your thoughts, I can assist you with any of those implementations.
    Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
    My posts, comments, code, and suggestions reflect only my personal views.
    Web Portfolio and Code Snippets: http://shanechism.com

  • Users who have thanked ShaneC for this post:

    Asela (04-21-2012)

  • #4
    New to the CF scene
    Join Date
    Apr 2012
    Location
    China
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Smile thanks you

    thank you very much tangoforce and ShaneC. yes I need to have a user visit a page and then, after a brief countdown, the file begins download.

    I think Sleep() will be useful in this case while displaying GIF which has count down.

    I found my way by your instructions.
    Best regards

  • #5
    Codeasaurus Rex
    Join Date
    Jun 2008
    Location
    Redmond, WA
    Posts
    659
    Thanks
    31
    Thanked 100 Times in 94 Posts
    Glad we could help! I've marked your thread as Resolved. Please let us know if you encounter any more difficulty!
    Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
    My posts, comments, code, and suggestions reflect only my personal views.
    Web Portfolio and Code Snippets: http://shanechism.com


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •