CodeIgniter上载错误未显示


CodeIgniter Upload Errors Not Showing

几天前,我一直在这里学习CodeIgniter文件上传教程。

在完成教程时,上传字段工作良好,显示了无效文件路径、类型和维度的错误。

但现在它只显示无效文件路径的错误,而不显示文件类型或维度的错误。当尝试上载无效的文件类型或维度时,上载字段将变为空白,没有错误消息。

这是我的代码:

上传控制器

<?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>

我已经解决了。

不得不在我的本地wamp服务器上修改post_max_size php.ini。