开发者

Downloaded FLV file is not working

Here is my code..

<?php
ob_clean();
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
// block any attempt to the filesystem
if (isset($params['file']) && basename($params['file']) == $params['file']) {

    $filename = $params['file'];

} else {

    $filename = NULL;

}

// define error message
$err = '<div class="right-panel fl">
                    <h1> Download Question </h1> <a href="JavaScript:void(0)" class="button" onclick="javascript:history.go(-1)" > Back </a>
                    <div class="gradient-box" style="margin-top:20px;" ><p style="color:#990000">Sorry, the file you are requesting is unavailable.</p></div></div>';

if开发者_JAVA百科 (!$filename) {

    // if variable $filename is NULL or false display the message
    echo $err;

} else {

    // define the path to your download folder plus assign the file name
    $path = BASE_PATH.QUESTIONS_FILE_PUBLIC.$filename;
    $path2 = REL_PATH.QUESTIONS_FILE.$filename;

    // check that file exists and is readable
    if (file_exists($path) && is_readable($path)) {

        // get the file size and send the http headers
        $size = filesize($path);
        header("Content-type: video/flv");
        header('Content-Length: '.$size);
        header('Content-Disposition: attachment; filename='.$filename);
        header('Content-Transfer-Encoding: binary');

        // open the file in binary read-only mode
        // display the error messages if the file can´t be opened
        echo file_get_contents($path);
        //@readfile($path);
        exit;
        $file = @ fopen($path, 'rb');

        if ($file) {

            // stream the file and exit the script when complete
            fpassthru($file);
            exit;

        } else {

            echo $err;

        }

    } else {

        echo $err;

    }

}
?>


Try to use function from this comment to force browser to open download file dialog. It must help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜