当前位置:Gxlcms > PHP教程 > 上传头像怎么保存图片?

上传头像怎么保存图片?

时间:2021-07-01 10:21:17 帮助过:30人阅读

index.php
========================================





Flash头像上传组件效果预览








function create_password($pw_length = 8)
{
$randpwd = '';
for ($i = 0; $i < $pw_length; $i++)
{
$randpwd .= chr(mt_rand(33, 126));
}
return $randpwd;
}

?>






sdcms.cn.php
===============================
/*
*仿新浪微博上传头像功能
*联系QQ:631897379
*演示:http://www.16934.net/demo
*png1,png2,png3分别为3个尺寸头像的参数,经过base64解密后保存即可
*/
$filename120 = "1_120.jpg";
$filename48 = "1_48.jpg";
$filename24 = "1_24.jpg";

$somecontent1=base64_decode($_POST['png1']);
$somecontent2=base64_decode($_POST['png2']);
$somecontent3=base64_decode($_POST['png3']);

if($handle=fopen($filename120,"w+"))
{
if(!fwrite($handle,$somecontent1)==FALSE)
{

fclose($handle);
}
}

if($handle=fopen($filename48,"w+"))
{
if(!fwrite($handle,$somecontent2)==FALSE)
{
fclose($handle);
}
}

if($handle=fopen($filename24,"w+"))
{
if(!fwrite($handle,$somecontent3)==FALSE)
{
fclose($handle);
}
}

echo "success=上传成功";
?>



回复讨论(解决方案)

你的$_FILES呢?
去看手册: $_FILES 你就明白了

人气教程排行