使用flexpaper从数据库中检索并显示swf文件



swf文件在数据库中有存储区,需要使用flextpaper进行显示

这是flexpaper显示文件的代码

$('#documentViewer').FlexPaperViewer(
    { config : {
    SWFFile : '<?php echo "present_retrieve.php?id=".$id.""; ?>',
    Scale : 0.6,
    ZoomTransition : 'easeOut',
    ZoomTime : 0.5,
    ZoomInterval : 0.2,
    FitPageOnLoad : true,
    FitWidthOnLoad : false,
    FullScreenAsMaxWindow : false,
    ProgressiveLoading : false,
    MinZoomSize : 0.2,
    MaxZoomSize : 5,
    SearchMatchAll : false,
    InitViewMode : 'Portrait',
    RenderingOrder : 'flash',
    StartAtPage : '',
    ViewModeToolsVisible : true,
    ZoomToolsVisible : true,
    NavToolsVisible : true,
    CursorToolsVisible : true,
    SearchToolsVisible : true,
    WMode : 'window',
    localeChain: 'en_US' }}

present_retrieve.php

<?php
// Connect to the database
        $host="localhost"; // Host name 
        $username="root"; // Mysql username 
        $password=""; // Mysql password 
        $db_name="is"; // Database name 
        $tbl_name="presentation"; // Table name 
        $conn = mysql_connect("$host", "$username", "$password"); 
        if(! $conn )
        {
          die('Could not connect: ' . mysql_error());
        }
        mysql_select_db($db_name);
    if (isset($_GET["id"]) && !empty($_GET["id"])) { 
            $id= $_GET['id'];
            $query = "SELECT file_name, file_type, file_size, content FROM $tbl_name WHERE file_id = '$id'";
            $result = mysql_query($query) or die(mysql_error()); 
                    $row1 = mysql_fetch_array($result);
                    $name=$row1['file_name'];
                    $type=$row1['file_type'];
                    $size = $row1['file_size'];
                    $content = $row1['content'];
            header("Content-length: $size");
            header("Content-type: $type");
            header("Content-Disposition: attachment; filename=$name");
            echo $content;
            mysql_close($conn);
            exit;
            }

?>

但是,该文件不会显示在柔性版纸中

请帮我弄清楚。非常感谢。

可能是您的输出中有多余的空间,这会损坏swf文件。检查php脚本中是否有任何前导或尾随空格(在php脚本标记之外)。

您的响应中也不需要内容处置标头。我建议swf文件使用以下标题:

标题("内容类型:应用程序/x-shockwave-flash");标头("Accept-Ranges:bytes");标头('Content-Length:'.$size);

最新更新