Home  >  Article  >  Backend Development  >  上传头像怎么保存图片?

上传头像怎么保存图片?

WBOY
WBOYOriginal
2016-06-23 14:05:151085browse

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


<script> <br /> function avatar_success() <br /> { <br /> alert("头像保存成功"); <br /> <br /> } <br /> </script>

 

Flash头像上传组件效果预览


" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="530" height="480">





function create_password($pw_length = 8)
{
    $randpwd = '';
    for ($i = 0; $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 你就明白了

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn