我们在作flash 在线拍照片时要保存由flash HTTP_RAW_POST_DATA过来的数据,我们就可把flash发送过来的图片数据保存起来,下面就来看看源码吧。
@session_start();
require_once("../Inc/Conn.php");
require_once("../Inc/function.php");
$filepath = '../userhead/';
$filename = time().mt_rand(10,100);
//$uid = get_id($_SESSION['uname']);
$uid = 14;
if (isset($GLOBALS["HTTP_RAW_POST_DATA"]))
{
$im = $GLOBALS["HTTP_RAW_POST_DATA"];
if( !is_dir( $filepath ) )
{
mkdir($filepath,0777);
}
if(file_put_contents($filepath.$filename.'.jpg',$im))
{
$path = 'http://'.$_SERVER['HTTP_HOST'].'/userhead/'.$filename.'.jpg';
savaPath($path);
}
else
{
ShowMsg('result:false');
}
}
function savaPath($path)
{
global $uid;
$sql = "Insert into dd(oy_uid,oy_dsp,oy_path) value('$uid','','$path')";
if( mysql_query( $sql ) )
{
ShowMsg('result:true');
}
else
{
ShowMsg('result:false'.mysql_error());
}
}
?>
本站原创转载注明:www.111cn.net/phper/php.html