后盾网-CI框架实例教程-马振宇

第九节视频:CI框架学习-实例操作发表文章之CI框架文件上传类缩略图类使用

 一、文件上传类的使用:

  在application ->controllers ->admin ->article.php

   1、配置

    $config["upload_path"] = "./uploads/";

    $config["allowed_type"] = "gif | jpg | png | jpeg";

    $config["max_size"] = "10000";

    $config["max_width"] = "1024";

    $config["max_height"] = "768";

    $config["file_name"] = time() . mt_rand(1000,9999);

   2、载入上传类

    $this ->load ->library("upload",$config);

   3、执行上传动作

    $status = $this ->upload ->do_upload("thumb");

   4、验证上传是否成功

     $wrong = $this ->upload ->display_errors();

      if($wrong){

      error($wrong);

        }

     5、返回信息

     $info = $this ->upload ->data();

       二、缩略图类(图像处理类)的使用:

    1、配置

     $arr["source_image"] = $info["full_path"];

        $arr["create_thumb"] = FALSE;

     $arr["maintain_ratio"] = TRUE;

        $arr["width"] = 200;

        $arr["height"] = 200;

    2、载入缩略图类

     $this ->load ->library("image_lib",$arr);

    3、执行动作

     $status = $this ->image_lib ->resize();

    4、验证缩略是否成功

      if(!$status){

        error("缩略图动作失败");

      }

原文地址:https://www.cnblogs.com/chengshun/p/7637099.html