【问题标题】:CodeIgniter Upload Errors Not ShowingCodeIgniter 上传错误未显示
【发布时间】:2015-12-10 07:34:21
【问题描述】:

几天前我一直在关注 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>

【问题讨论】:

  • 表单的操作在哪里??
  • 使$config 类似于文档的示例。

标签: php forms codeigniter error-handling upload


【解决方案1】:

我已经解决了。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-12-09
    • 2016-09-22
    • 2017-01-16
    • 2016-12-11
    • 2019-04-27
    • 2012-07-12
    相关资源
    最近更新 更多