和存图片的方法一样.显示时输出
header("Content-type: application/x-shockwave-flash");
//下面是输出flash文件内容:
.....

解决方案 »

  1.   

    addslashes ()
    striplashes ()
      

  2.   

    我的代码如下,但我看不到正常效果~
    send.php读FLASH文件,view.php显示FLASH,swf.php读取FLASH数据#####################      send.php    ############################<?include("config.php");
    if($swf_name!=""){
           $swf_data=addslashes(fread(fopen($swf,"r"),filesize($swf)));
           if($swf_type!="application/x-shockwave-flash"){echo "<center>图片只能是JPG图片</center>";exit;}
           $str="insert into tmp values ('','$swf_data','$swf_type')";
           mysql_query($str);
           if(mysql_affected_rows()==1){ echo "<center>成功</center>"; }
           else    {  echo "<center>失败</center>" ;   }
    }
    ?>
    <html>
    <head>
    <title>发布</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <center>
      <form name="form"  enctype="multipart/form-data"  method="post" action="">
        <table width="60%" border="1">
          <tr>
            <td width="31%" align="center">照片</td>
            <td width="69%">
              <input type="file" name="swf">
            </td>
          </tr>
          <tr align="center">
            <td colspan="2">
              <input type="submit" name="submit" value="提交">
              <input type="reset" name="reset" value="重置">
            </td>
          </tr>
        </table>
    </form>
    </center>
    </body>
    </html>
    <?mysql_close();?>
    #####################      view.php    ############################<html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head>
    <body>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="778" height="82">
      <param name="movie" value="swf.php?id=1">
      <param name="quality" value="high">
      <embed src="swf.php?id=1" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="778" height="82"></embed>
    </object>
    </body>
    </html>
    #####################      swf.php    ############################<?
    include("config.php");
    if($id){
    $query="select picture_data,picture_type from tmp where id=$id";
    $result=MYSQL_QUERY($query);
    $data=MYSQL_RESULT($result,0,"picture_data");
    $type=MYSQL_RESULT($result,0,"picture_type");
    Header("Content-type:$type");
    echo $data;
    };?>
      

  3.   

    send.php文件里的错误提示需要纠正,因为我是从操作图片的程序改来的,应该不会影响吧。
      

  4.   

    结果我在浏览view.php的时候要等待很久很久,还显示不出来。
      

  5.   

    ************************** view.php ******************************
    <html>
    <head>
    <title>View swf</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head>
    <body>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="378" height="182">
      <param name="movie" value="swf.php?id=<?=$_GET['id']?>">
      <param name="quality" value="high">
      <embed src="swf.php?id=<?=$_GET['id']?>" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="778" height="82"></embed>
    </object>
    </body>
    </html>
    ************************** swf.php ******************************
    <?php
    include("config.php");
    if($_GET['id']){
    $query="select * from $swf_db where id=".$_GET['id'];
    $result=mysql_query($query);
    $res = mysql_fetch_array($result);Header("Content-type:{$res['type']}");
    print(base64_decode($res['data']));
    };
    ?>************************** send.php ******************************<html>
    <head>
    <title>发布</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <?php
    include("config.php");
    if($_FILES['swf_file']['tmp_name'] != ""){
    $SSize = filesize($_FILES['swf_file']['tmp_name']);
    $data = addslashes(base64_encode(fread(fopen($_FILES['swf_file']['tmp_name'], "rb"), $SSize) )) ;
    unlink($_FILES['swf_file']['tmp_name']);
    if(!mysql_query("INSERT INTO $swf_db (data,type) VALUES ('$data','{$_FILES['swf_file']['type']}');")) echo "写入失败";
    else echo "writen OK!";
    }
    else {
    echo"NO picture";
    }
    ?>
    <center>
      <form name="form"  enctype="multipart/form-data"  method="post" action="<?=$_SERVER['PHP_SELF']?>">
        <table width="60%" border="1">
          <tr>
            <td width="31%" align="center">照片</td>
            <td width="69%">
              <input type="file" name="swf_file">
            </td>
          </tr>
          <tr align="center">
            <td colspan="2">
              <input type="submit" name="submit" value="提交">
              <input type="reset" name="reset" value="重置">
            </td>
          </tr>
        </table>
    </form>
    </center>
    </body>
    </html>
      

  6.   

    谢谢netvt(唯她)!你的代码主要加了对文件base64_encode()操作,我把我自己代码按照你的改了,还是等好久都显示不出来FLASH;又运行你的代码,也不行,没有加载FLASH文件。
      

  7.   

    文件过大,会上传失败.!!!!!!!!!如果上传成功的话,是可以加载的..
    你先上传小一点的文件试试.我这里测试通过!data字段用LONGBLOB类型.
      

  8.   

    非常感谢·!我也测试通过了!我知道把FLASH文件放到数据库内不是很不好,太占资源,但我不知道如何可以做到防止盗链,能帮我吗?
      

  9.   

    上传时把文件复制到WEB目录区以外.读取时,用PHP读文件内容输出..