Home > php教程 > PHP开发 > CI Framework Notes 3

CI Framework Notes 3

黄舟
Release: 2016-12-29 09:39:08
Original
1281 people have browsed it

File Upload Class

<?php
public function do_upload()
{
$config[&#39;upload_path&#39;] = &#39;./uploads/&#39;;
$config[&#39;allowed_types&#39;] = &#39;gif|jpg|png&#39;;
$config[&#39;max_size&#39;] = 100;
$config[&#39;max_width&#39;] = 1024;
$config[&#39;max_height&#39;] = 768;
//载入上传类
$this->load->library(&#39;upload&#39;, $config);
//执行上传
if ( ! $this->upload->do_upload(&#39;userfile&#39;))
{
$error = array(&#39;error&#39; => $this->upload->display_errors());
$this->load->view(&#39;upload_form&#39;, $error);
}
else
{ //上传返回的信息
$data = array(&#39;upload_data&#39; => $this->upload->data());
$this->load->view(&#39;upload_success&#39;, $data);
}
}
public function shangchuan(){
$info = $this->upload->data();
//上传缩略图----------------配置
$config[&#39;source_image&#39;]=$info[&#39;full_path&#39;];
$config[&#39;create_thumb&#39;]=TRUE;//创建预览图像
$config[&#39;width&#39;]=75;
$config[&#39;height&#39;]=50;
//载入 
$this->load->library(&#39;image_lib&#39;,$config);
//执行动作
$status = $this ->image_lib ->resize();
if(!$status){
error(&#39;缩略图失败&#39;);
}
}
?>
Copy after login

The above is the content of CI Framework Note 3. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template