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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Location
    Pakistan
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts

    query about file downloading

    Hi all
    i have two sections in my project
    1; admin
    2; site users
    i m providing the facility for users to come to my site and download files.
    all the users have credit accounts. when a user downloads a file, his account will be minus by one credit and the account of admin will be plus by one credit.
    its all working fine for me.
    the problem is
    how i come to know that a user has just opened the file or he has download it.
    bcoz in my case, whether a user opens, downloads the file or even cancels , the account gets plus by one.
    God helps those who help others.

  • #2
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I was actually thinking about this the other day. I was wondering if doing something like this would solve your problem:
    Code:
    <?php
    header('Content-type: the/proper/type/goes/here');
    readfile($somefile);
    
    query($sql_to_run_when_file_is_done_downloading);
    
    ?>
    if that won't do it then I'm not sure what will. oh, and on that note, anyone know if doing an fgets+ob_flush would let one control the speed of the download?
    Last edited by fci; 02-10-2006 at 03:21 PM.

  • #3
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You cannot detect that.

    All you can detect is that the command was processed.

    e.g.
    If you use content headers to force a download then when the file is requested it will prompt the user to open or download the file.

    As soon as this prompt is given then it's upto the user to open or cancel. Your script has done it's job.


  •  

    Posting Permissions

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