Force download PHP - not downloading the whole file

I have a problem with forcing download of some mp3/zip files.

The problem is that some users experiences that the whole file isn't downloaded, and i can't figure out why..


        Do any processing you'd like here:
        1.  Increment a counter
        2.  Do something with the DB
        3.  Check user permissions
        4.  Anything you want!

    // required for IE
    if(ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); }

    // get the file mime type using the file extension
        case 'mp3': $mime = 'audio/mpeg'; break;
        case 'zip': $mime = 'application/zip'; break;
        default: $mime = 'application/force-download';
    header('Pragma: public');   // required
    header('Expires: 0');       // no cache
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Last-Modified: '.gmdate ('D, d M Y H:i:s', filemtime ($file_name)).' GMT');
    header('Cache-Control: private',false);
    header('Content-Type: '.$mime);
    header('Content-Disposition: attachment; filename="'.basename($file_name).'"');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: '.filesize($file_name));    // provide file size
    header('Connection: close');
    readfile($file_name);       // push it out


here is my code..

Any ideas?


Thanks for all of your help,

but i found another solution to my problem, and used mod_xsendfile instead. It has done the job for me :)

Need Your Help

How To Apply Bounds in Unity For iOS devices

c# unity3d game-physics unityscript

I've made an unity game for iOS devices. It has a game object(sphere) which moves by the force applied to it. But I want to limit the sphere within the screen bounds.