zoukankan      html  css  js  c++  java
  • 图片上传加水印

    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 ThinkImage();
    // 添加水印
    //$image->open(".".$imgpath1)->water("./Uploads/company/logo.png",ThinkImage::IMAGE_WATER_SOUTHEAST,30)-> save(".".$imgpath1);
    //$image->open(".".$imgpath2)->water("./Uploads/company/logo.png",ThinkImage::IMAGE_WATER_SOUTHEAST,30)-> save(".".$imgpath2);
    //$image->open(".".$imgpath3)->water("./Uploads/company/logo.png",ThinkImage::IMAGE_WATER_SOUTHEAST,30)-> save(".".$imgpath3);
    //$image->open(".".$imgpath4)->water("./Uploads/company/logo.png",ThinkImage::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');
    }
    }

    A buddhist programmer.
  • 相关阅读:
    Prism之12345
    Struts2注解学习1
    模拟Spring依赖注入
    Spring的IOC注解学习
    Hibernate注解学习1
    Redis源码分析(二十六) slowLog和hyperloglog
    做优秀产品经理所需的7种素质
    程序员学习英语
    PL/SQL Developer记住密码设置
    oracle11g,安装及net Manager的配置
  • 原文地址:https://www.cnblogs.com/wszz/p/8275331.html
Copyright © 2011-2022 走看看