@header("Expires: 0");
@header("Cache-Control: private, post-check=0, pre-check=0, max-age=0", FALSE);
@header("Pragma: no-cache");
define('SD_ROOT', dirname(__FILE__).'/');
$pic_id = time();//使用时间来模拟图片的ID.
$pic_path = SD_ROOT.'./avatar_origin/'.$pic_id.'.jpg';
//上传后图片的绝对地址
//$pic_abs_path = 'http://sns.com/avatar_test/avatar_origin/'.$pic_id.'.jpg';
$pic_abs_path = 'avatar_origin/'.$pic_id.'.jpg';
//保存上传图片.
if(empty($_FILES['Filedata'])) {
echo '';
exit();
}
$file = @$_FILES['Filedata']['tmp_name'];
file_exists($pic_path) && @unlink($pic_path);
if(@copy($_FILES['Filedata']['tmp_name'], $pic_path) || @move_uploaded_file($_FILES['Filedata']['tmp_name'], $pic_path))
{
@unlink($_FILES['Filedata']['tmp_name']);
/*list($width, $height, $type, $attr) = getimagesize($pic_path);
if($width < 10 || $height < 10 || $width > 3000 || $height > 3000 || $type == 4) {
@unlink($pic_path);
return -2;
}*/
} else {
@unlink($_FILES['Filedata']['tmp_name']);
echo '';
}
//写新上传照片的ID.
echo '';
?>