zoukankan      html  css  js  c++  java
  • thinkphp图片上传缩略图代码解释

    PHP代码如下(附说明):

     

     1     public function add(){
     2         if(IS_POST){
     3             $goods = M("goods");
     4             $data = $_POST;
     5             $data["on_time"] = date('Y-m-d H:s');
     7             $conf = array(
     8                 "rootPath" => "./app/upload/"
     9             );
    10             $uploads = new upload($conf);
    11             $info = $uploads -> uploadOne($_FILES["original_img"]);
    14             $data["original_img"] = $info["savepath"].$info["savename"];
    16             $image = new Image();
    17             $big_img = $uploads ->rootPath.$info["savepath"].$info["savename"];
    19             $image ->open($big_img);
    21             $image ->thumb(150,150,6);
    23             $small_img = $uploads ->rootPath.$info["savepath"].'small_'.$info["savename"];
    24             $image ->save($small_img);
    25             $data['keywords'] = $info["savepath"].'small_'.$info["savename"];
    26             $goods -> add($data);
    27             $this -> redirect("zhanshi",array(),1,"添加成功");
    28             
    29         }

     

     

     

     

     

     

    html视图代码(附说明):

     

    1 <td><img src="{$Think.const.UPLOAD_PATH}{$vo.original_img}" height="60" width="60"></td>
    2 <td><img src="{$Think.const.UPLOAD_PATH}{$vo.keywords}" height="40" width="40"></td>

     

     

      路径常量代码(附说明):

     1 define("UPLOAD_PATH","http://localhost/ThinkPHP/app/upload/"); 

     

    基本效果展示:

     

     

     

     

     

     

  • 相关阅读:
    2021/1/10周总结一
    java基础复习五
    java基础复习四
    构建之法读书笔记三
    javaweb学生教务系统
    java基础复习三
    关于eclipse项目错误的一些小经验总结
    Java基础复习二
    JavaDoc文档
    2017-2018-2 20179216 《网络攻防与实践》 第四周总结
  • 原文地址:https://www.cnblogs.com/lxc-bky/p/9883093.html
Copyright © 2011-2022 走看看