1

swf 文件已存储在数据库中,需要使用 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;
            }


?>

但是,该文件未显示在 flexpaper 中

请帮我弄清楚。谢谢你。

4

1 回答 1

0

It could be that you have an extra space somewhere in your output and that this is corrupting the swf file. Check for any leading or trailing spaces in your php script (outside the php script tags).

You also don't need the content-disposition header in your response. I would recommend the following headers for swf files:

header('Content-type: application/x-shockwave-flash'); header('Accept-Ranges: bytes'); header('Content-Length: ' . $size);

于 2014-04-17T02:14:39.523 回答