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

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

This is code for flexpaper display file.

$('#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.

Please help me to figure out. Thank you.

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