【问题标题】:How to Upload Image files Using Codeigniter? [closed]如何使用 Codeigniter 上传图像文件? [关闭]
【发布时间】:2013-03-21 02:42:21
【问题描述】:

如何使用 Codeigniter 上传图片文件? Codeigniter's Upload class Library

没有提示如何使用简单的表单上传图像并将图像上传到根目录中的图像文件夹...

提前谢谢..

【问题讨论】:

  • 该页面实际上确实解释了您刚刚询问的所有内容。用户上传图片到表单框,CI解析并下载到服务器。
  • 如何删除这个问题?

标签: php file codeigniter upload


【解决方案1】:

这是一个例子。希望这对你有帮助:)

在您的控制器中。假设upload.php

public function upload() {
    if($this->input->post('upload')) {

        $config['upload_path'] = APPPATH . 'your upload folder name here/'; 
        $config['file_name'] = filename_here;
        $config['overwrite'] = TRUE;
        $config["allowed_types"] = 'jpg|jpeg|png|gif';
        $config["max_size"] = 1024;
        $config["max_width"] = 400;
        $config["max_height"] = 400;
        $this->load->library('upload', $config);

        if(!$this->upload->do_upload()) {               
            $this->data['error'] = $this->upload->display_errors();
        } else {
            //success                                      
        }  
    }
}

那么在你看来

<?php echo form_open_multipart('upload'); ?>    
<?php echo form_upload('userfile'); ?><br />
<?php echo form_submit('upload', 'Upload');?>    
<?php echo form_close(); ?>

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多