时间:2021-07-01 10:21:17 帮助过:4人阅读
运用的是jquery中的插件,温馨提示请下载好js。
x
取消
取消
照片里必须有你本人 如果你放裸照,局部照,宠物,车,风景,艺术作品等,你的照片或账户将被删除
— 适友提示
//下面的是php代码
public function photoupload(){
session_start();
$user = M('User_photo');
$con0 = $user->query("select COUNT(id) as CON from cup_user_photos where
user_id='".session('user_id')."'");
if($con0[0]['CON']>=5){
echo "10101";
}else{
import("ORG.Net.UploadFile");
$upload = new UploadFile();// 实例化上传类
$upload->maxSize = 3145728 ;// 设置附件上传大小
$upload->saveRule = time();
$upload->thumb = true;
$upload->thumbMaxWidth = "1024";
$upload->thumbMaxHeight = "768";
$upload->thumbRemoveOrigin = true;
$upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
$upload_file="public/image/".date('Ymd')."/".session('username')."/";
$upload_dir=create_folders($upload_file);
$upload->savePath = $upload_dir;// 设置附件上传目录
//给图片加水印
import('ORG.Util.Image');
$Image = new Image();
$uploadfile='/'.$info[0]['savepath'].'thumb_'.$info[0]['savename'];
$Image->water($uploadfile,'/public/image/1336954430057.png');
if(!$upload->upload()) {// 上传错误提示错误信息
$this->error($upload->getErrorMsg());
}else{// 上传成功 获取上传文件信息
$info =$upload->getUploadFileInfo();
//给m_缩略图添加水印, Image::water('原文件名','水印图片地址')
//给图片加水印
$uploadfile='/'.$info[0]['savepath'].'thumb_'.$info[0]['savename'];
echo $uploadfile;
}
}
}
//如果想要上传后并有剪切功能请看下个帖子