• Resolved xyhavoc

    (@xyhavoc)


    Hello @imath,

    I’ve run into this problem for the second time now. It seems that after a while of the Buddydrive plugin being installed and correctly functional, for some reason files being delivered through the PHP end up being corrupted. The first time I encountered the problem with Buddydrive 1.1.1, I was able to fix the issue by adding an ob_flush() or ob_clean() to the php code that delivers the buddydrive file. Since Buddydrive 1.2 I didn’t bother adding ob_flush/clean again, yet everything was working fine. Now all of a sudden I am experiencing corrupt downloads once again.

    I am searching through all the Buddydrive files looking for the script that delivers the download to the user and cannot seem to find it so I can add the ob_flush/clean code again. Could you point me in the right direction to fix this? And is it possible you could add this to your next version.

    https://wordpress.org/plugins/buddydrive/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter xyhavoc

    (@xyhavoc)

    I seem to have fixed it.

    The file I was looking for is:
    buddydrive-item-actions.php

    starting on line 183:

    // we have a file! let's force download.
    		if ( file_exists( $buddydrive_file_path ) && !empty( $can_donwload ) ){
    			do_action( 'buddydrive_file_downloaded', $buddydrive_file );
    			status_header( 200 );
    			header( 'Cache-Control: cache, must-revalidate' );
    			header( 'Pragma: public' );
    			header( 'Content-Description: File Transfer' );
    			header( 'Content-Length: ' . filesize( $buddydrive_file_path ) );
    			header( 'Content-Disposition: attachment; filename='.$buddydrive_file_name );
    			header( 'Content-Type: ' .$buddydrive_file_mime );
    			readfile( $buddydrive_file_path );
    			die();
    		}

    Add this to line 193:
    ob_end_clean();

    before the line:
    readfile( $buddydrive_file_path );

    No more corrupt file downloads delivered through the PHP.

    Plugin Contributor Mathieu Viet

    (@imath)

    hi @xyhavoc

    thanks for sharing, i look at it and try to include that in a next release.

    I’ve had the same issue for a couple of versions as well. Same fix applied here as well.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Corrupt files delivered through PHP, Buddydrive needs ob_clean or ob_flush’ is closed to new replies.