我几天前一直在关注CodeIgniter文件上传教程here。
在完成本教程时,上传字段工作正常,显示无效文件路径,类型和尺寸的错误。
但现在它只显示无效文件路径和错误,但不显示文件类型或维度。尝试上传无效的文件类型或维度时,上传字段将变为空白,没有错误消息。
这是我的代码:
上传控制器
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Upload extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->helper("form");
$this->load->helper("url");
}
public function index()
{
$this->load->view("templates/index");
}
public function upload_form()
{
$this->load->library("upload_helper");
$config = $this->upload_helper->upload_config("./static_repo/uploads/", "gif|jpg|png", 100, 1024, 768);
$this->load->library("upload", $config);
if(!$this->upload->do_upload("userfile"))
{
$data = array(
"error" => $this->upload->display_errors()
);
$this->load->view("upload/upload_form_page", $data);
}
else
{
$data = array(
"upload_data" => $this->upload->data()
);
$this->load->view("upload/upload_success_page", $data);
}
}
} //end class Upload
HTML表单
<?= $error ?>
<form enctype="multipart/form-data" method="post">
<input type="file" name="userfile" size="20">
<br/><br/>
<input class="btn btn-default" type="submit" value="upload"/>
</form>
答案 0 :(得分:0)
我已经解决了。
必须在我的本地wamp服务器上修改post_max_size php.ini。