【发布时间】:2017-09-22 02:07:27
【问题描述】:
CodeIgniter 无法加载请求的文件:upload_form.php
我遇到了这种类型的错误。
这是我正在上传的控制器文件。 控制器 上传.php
class Upload extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
}
public function index()
{
$this->load->view('upload_form', array('error' => ' ' ));
}
public function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['max_size'] = 100;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload');
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('userfile'))
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
}
}
}
我在这里上传我的视图文件。 查看 上传表单.php
<?php echo $error; ?>
<?php echo form_open_multipart('upload/do_upload'); ?>
<input type="file" name="userfile" size="20">
<input type="submit" value="upload">
<?php echo form_close(); ?>
【问题讨论】:
-
试过用谷歌搜索这个吗?
-
你的问题太宽泛了。有太多可能的答案。 SO 不是一个讨论平台。
-
我编辑了这个问题,因为我无法在 3 天前提出新问题。
标签: php codeigniter file-upload