【发布时间】:2016-02-26 10:20:44
【问题描述】:
我正在尝试从 CodeIgniter 上传文件。文件没有给出任何错误,甚至没有将文件存储在根目录或 codeigniter 中的上传文件夹中。有人可以帮忙吗?请注意,因为我已经向我的上传文件夹授予了 755 权限。下面是我的代码
查看文件
<html>
<head>
<title>Upload Form</title>
</head>
<body>
<?php echo $error;?>
<?php echo form_open_multipart('UploadController');?>
<input type="file" name="userfile" size="20" />
<br /><br />
<input type="submit" value="upload" />
</form>
</body>
</html>
下面是我的控制器
<?php
class UploadController extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
}
function index()
{
$this->load->view('uploadview', array('error' => ' ' ));
}
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload("add_1"))
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('uploadview', $data);
}
}
}
?>
请在这个问题上帮助我。
【问题讨论】: