把SWF文件放到数据库下! 和存图片的方法一样.显示时输出header("Content-type: application/x-shockwave-flash");//下面是输出flash文件内容:..... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 addslashes ()striplashes () 我的代码如下,但我看不到正常效果~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;};?> send.php文件里的错误提示需要纠正,因为我是从操作图片的程序改来的,应该不会影响吧。 结果我在浏览view.php的时候要等待很久很久,还显示不出来。 ************************** 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 ******************************<?phpinclude("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"><?phpinclude("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> 谢谢netvt(唯她)!你的代码主要加了对文件base64_encode()操作,我把我自己代码按照你的改了,还是等好久都显示不出来FLASH;又运行你的代码,也不行,没有加载FLASH文件。 文件过大,会上传失败.!!!!!!!!!如果上传成功的话,是可以加载的..你先上传小一点的文件试试.我这里测试通过!data字段用LONGBLOB类型. 非常感谢·!我也测试通过了!我知道把FLASH文件放到数据库内不是很不好,太占资源,但我不知道如何可以做到防止盗链,能帮我吗? 上传时把文件复制到WEB目录区以外.读取时,用PHP读文件内容输出.. php分页类的问题 SQL php图片上传问题 LAMP兄弟连[6月28-7月5日]期间在线讲座汇总 新年到了!!! 散分 老话题,缩略图相关 ThinkPHP框架的网址,本地正常,传到服务器出现一些问题 还是关于【关于php数组排序的问题?】 聊天室很多说话的人,当我点击某人的名字是,能表示对这个人说话,如何实现(鸟儿兄请进) 请帮忙修改《电脑报》11月12日中介绍的一个简单的PHP聊天室 请教:关于web页面跳转 如何在msyql中存储图片以及如何在页面显示
striplashes ()
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;
};?>
<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>
你先上传小一点的文件试试.我这里测试通过!data字段用LONGBLOB类型.