图片上传加水印

public function add(){
$comca=M('Comca');
$cominfo=M('Cominfo');
$perinfo=M('Perinfo');
$user=M('User');
$com_code=$_POST['com_code'];
$comcr_name=$_POST['comcr_name'];
$comcr_code=$_POST['comcr_code'];
$file1 = $_FILES['file1'];
$file2 = $_FILES['file2'];
$file3 = $_FILES['file3'];//得到传输的数据
$file4 = $_FILES['file4'];//得到传输的数据
$name1 = $file1['name'];//得到文件名称
$name2 = $file2['name'];//得到文件名称
$name3 = $file3['name'];//得到文件名称
$name4 = $file4['name'];//得到文件名称

$type1 = strtolower(substr($name1,strrpos($name1,'.')+1)); //得到文件类型,并且都转化成小写
$type2 = strtolower(substr($name2,strrpos($name2,'.')+1)); //得到文件类型,并且都转化成小写
$type3 = strtolower(substr($name3,strrpos($name3,'.')+1)); //得到文件类型,并且都转化成小写
$type4 = strtolower(substr($name4,strrpos($name4,'.')+1)); //得到文件类型,并且都转化成小写
$allow_type = array('jpg','jpeg','png'); //定义允许上传的类型
//判断文件类型是否被允许上传

$user_account=$_SESSION['user_account'];
$userid = $user->where("user_account='$user_account'")->getField('user_id');

$upload_path = "D:/WebSite/program/Uploads/company/"; //上传文件的存放路径

//开始移动文件到相应的文件夹
move_uploaded_file($file1['tmp_name'],iconv('utf-8', 'gbk',$upload_path.$userid."com_codeimg".".".$type1));
move_uploaded_file($file2['tmp_name'],iconv('utf-8', 'gbk',$upload_path.$userid."com_orgimg".".".$type2));
move_uploaded_file($file3['tmp_name'],iconv('utf-8', 'gbk',$upload_path.$userid."comcr_caimg".".".$type3));
move_uploaded_file($file4['tmp_name'],iconv('utf-8', 'gbk',$upload_path.$userid."comcr_codeimg".".".$type4));

//图片路径
$imgpath1="/Uploads/company/".$userid."com_codeimg.".$type1;
$imgpath2="/Uploads/company/".$userid."com_orgimg.".$type2;
$imgpath3="/Uploads/company/".$userid."comcr_caimg.".$type3;
$imgpath4="/Uploads/company/".$userid."comcr_codeimg.".$type4;

$image = new \Think\Image();
// 添加水印
//$image->open(".".$imgpath1)->water("./Uploads/company/logo.png",\Think\Image::IMAGE_WATER_SOUTHEAST,30)-> save(".".$imgpath1);
//$image->open(".".$imgpath2)->water("./Uploads/company/logo.png",\Think\Image::IMAGE_WATER_SOUTHEAST,30)-> save(".".$imgpath2);
//$image->open(".".$imgpath3)->water("./Uploads/company/logo.png",\Think\Image::IMAGE_WATER_SOUTHEAST,30)-> save(".".$imgpath3);
//$image->open(".".$imgpath4)->water("./Uploads/company/logo.png",\Think\Image::IMAGE_WATER_SOUTHEAST,30)-> save(".".$imgpath4);

$phone=$user->where("user_account='$user_account'")->getField('user_phone');
$exe=$comca->where("user_account='$user_account'")->find();
if($exe){
//$comca->execute("update comca set com_code='$com_code',comcr_name='$comcr_name',comcr_code=$comcr_code',com_codeimg='$imgpath1',com_orgimg='$imgpath2',comcr_caimg='$imgpath3',comcr_codeimg='$imgpath4',comca_status='待审核',comca_submittime=now() where user_account='$user_account'");
$data['com_code'] = $com_code;
$data['comcr_name'] = $comcr_name;
$data['comcr_code'] = $comcr_code;
$data['com_codeimg'] = $imgpath1;
$data['com_orgimg'] = $imgpath2;
$data['comcr_caimg'] = $imgpath3;
$data['comcr_codeimg'] = $imgpath4;
$data['comca_status'] = '待审核';
$data['comca_submittime'] = date("Y-m-d H:i:s");
$comca->where("user_account='$user_account'")->save($data); // 根据条件更新记录
$cominfo->execute("update cominfo set user_name='$comcr_name',com_user='$comcr_name',user_phone='$phone' where user_account='$user_account'");
$user->execute("update user set user_comstatus='待审核',user_type='company' where user_account='$user_account'");
$this->redirect('/home/realphoto/submit');
}else{
$comca->execute("insert into comca (user_account,com_code,comcr_name,comcr_code,com_codeimg,com_orgimg,comcr_caimg,comcr_codeimg,comca_submittime,comca_status) values ('$user_account','$com_code','$comcr_name','$comcr_code','$imgpath1','$imgpath2','$imgpath3','$imgpath4',now(),'待审核')");
$cominfo->execute("update cominfo set user_name='$comcr_name',com_user='$comcr_name',user_phone='$phone' where user_account='$user_account'");
$user->execute("update user set user_comstatus='待审核',user_type='company' where user_account='$user_account'");
$this->redirect('/home/realphoto/submit');
}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值