第九节视频:CI框架学习-实例操做发表文章之CI框架文件上传类与缩略图类使用php
1、文件上传类的使用:app
在application ->controllers ->admin ->article.php框架
一、配置学习
$config["upload_path"] = "./uploads/";this
$config["allowed_type"] = "gif | jpg | png | jpeg";视频
$config["max_size"] = "10000";文件上传
$config["max_width"] = "1024";io
$config["max_height"] = "768";图像处理
$config["file_name"] = time() . mt_rand(1000,9999);配置
二、载入上传类
$this ->load ->library("upload",$config);
三、执行上传动做
$status = $this ->upload ->do_upload("thumb");
四、验证上传是否成功
$wrong = $this ->upload ->display_errors();
if($wrong){
error($wrong);
}
五、返回信息
$info = $this ->upload ->data();
2、缩略图类(图像处理类)的使用:
一、配置
$arr["source_image"] = $info["full_path"];
$arr["create_thumb"] = FALSE;
$arr["maintain_ratio"] = TRUE;
$arr["width"] = 200;
$arr["height"] = 200;
二、载入缩略图类
$this ->load ->library("image_lib",$arr);
三、执行动做
$status = $this ->image_lib ->resize();
四、验证缩略是否成功
if(!$status){
error("缩略图动做失败");
}