Jump to content

Incomplete Downloads with Wordpress Script


citizen_insane

Recommended Posts

I've been using a modified version of the Wodpress Download Codes plugin for a record label website that I've created that allows people to download digital albums. The zip files are about 130mb +-20mb. The issue we're having is with some users reporting issues of incomplete downloads. The download will finish (doesn't stop in the middle) but it will be a different size than the file hosted on the server. This leads me to believe that the file is only partially downloading thus corrupting the zip file.

 

The issue has been reported on all operating systems and browsers, but I have never witnessed it myself, just gotten the feedback from users/testers. Here is the code used to stream the file, can anyone see a reason why I would be having issues?

 

// Stream file
        $handle = fopen( dc_file_location() . $release->filename, 'rb' );
        $chunksize = 1*(1024*1024);
        $buffer = '';
        $cnt =0;
                if ($handle === false) {
                        return false;
                }
                while (!feof($handle)) {
                        $buffer = fread($handle, $chunksize);
                        echo $buffer;
                        ob_flush();
                        flush();
                        if ($retbytes) {
                                $cnt += strlen($buffer);
                        }
                }
                $status = fclose($handle);
                if ($retbytes && $status) {
                        return $cnt; // return num. bytes delivered like readfile() does.
                }
                return $status;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.