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

时间:2022-09-25 21:36:56

swf file has store inside database and need to display using flexpaper.

swf文件存储在数据库中,需要使用flexpaper显示。

This is code for flexpaper display file.

这是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;
            }


?>

However, the file doesn't show in the flexpaper.

但是,该文件不会在flexpaper中显示。

Please help me to figure out. Thank you.

请帮我搞清楚。谢谢。

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).

可能是你的输出中有一个额外的空间,这会破坏swf文件。检查php脚本中的任何前导或尾随空格(在php脚本标记之外)。

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

您还不需要在响应中使用content-disposition标头。我建议使用swf文件的以下标题:

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

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

#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).

可能是你的输出中有一个额外的空间,这会破坏swf文件。检查php脚本中的任何前导或尾随空格(在php脚本标记之外)。

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

您还不需要在响应中使用content-disposition标头。我建议使用swf文件的以下标题:

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

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