博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
图片上传加水印
阅读量:5308 次
发布时间:2019-06-14

本文共 4036 字,大约阅读时间需要 13 分钟。

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');
}
}

转载于:https://www.cnblogs.com/wszz/p/8275331.html

你可能感兴趣的文章
web前端之路,js的一些好书(摘自聂微东 )
查看>>
【模板】对拍程序
查看>>
【转】redo与undo
查看>>
解决升级系统导致的 curl: (48) An unknown option was passed in to libcurl
查看>>
Java Session 介绍;
查看>>
spoj TBATTLE 质因数分解+二分
查看>>
Django 模型层
查看>>
dedecms讲解-arc.listview.class.php分析,列表页展示
查看>>
Extjs6 经典版 combo下拉框数据的使用及动态传参
查看>>
【NodeJS】http-server.cmd
查看>>
研磨JavaScript系列(五):奇妙的对象
查看>>
面试题2
查看>>
selenium+java iframe定位
查看>>
P2P综述
查看>>
第五章 如何使用Burp Target
查看>>
Sprint阶段测试评分总结
查看>>
sqlite3经常使用命令&语法
查看>>
linux下编译openjdk8
查看>>
【python】--迭代器生成器装饰器
查看>>
Pow(x, n)
查看>>