I got a problem when i am trying to blow a tumble bit from file to client. If a file download complete and success full so everything ok

but when the downloading has stop becase of disconnect or closing by user  code die at all even file handle has not been closed

Thanks for all answers! I find a way to solve problem. May be output buffer is the reason for this problem. I run flush(),ob_flush() functions after output and solve the problem! Again thanks alot.

<?php
    ignore_user_abort (TRUE);

    $x=0;
    while ($x++ < 10) {
      print " ";
      flush();
      ob_flush();
      sleep (1);
    }

    switch (connection_status ()) {
    case CONNECTION_NORMAL:
       $status = 'Normal';
       break;
    case CONNECTION_ABORTED:
       $status = 'User Abort';
       break;
    case CONNECTION_TIMEOUT:
       $status = 'Max Execution Time exceeded';
       break;
    case (CONNECTION_ABORTED & CONNECTION_TIMEOUT):
       $status = 'Aborted and Timed Out';
       break;
    default:
       $status = 'Unknown';
       break;
    }

    file_put_contents('testa.txt',$status);
    ?>
Advertisements