【问题标题】:Internal server error during file upload文件上传期间的内部服务器错误
【发布时间】:2013-12-10 08:58:35
【问题描述】:

这是我的前端代码。这是一个小表格,带有一个input 用于文件上传。

<form class="" method="POST" action="<?php echo base_url();?>adminpanel/upload" enctype="multipart/form-data">

                          <input type="file" name="file">
                        <div class="widget-footer">
                            <button class="btn btn-primary" type="submit">Save</button>

                        </div>
                      </form>

当我点击保存按钮时,会执行以下 PHP 脚本:

 function upload()
    {      
           ini_set('upload_max_filesize', '10M');
           ini_set('post_max_size', '10M');
           if (!empty($_FILES))
        {
            $config['upload_path'] = './uploads/';
            $config['allowed_types'] = 'gif|jpg|png';
            $config['max_size'] = '2000';


            $this->load->library('upload', $config);
            if ($this->upload->do_upload())
            {   //success
                $data = array('upload_data' => $this->upload->data());
            }


        }
                redirect("/home");
    }

但我没有成功上传文件,而是收到以下消息:

内部服务器错误 服务器遇到内部错误或配置错误,无法完成您的请求。 请联系服务器管理员 admin@localhost 并告知他们错误发生的时间,以及您所做的任何可能导致错误的事情。 服务器错误日志中可能会提供有关此错误的更多信息

当我转到 Apache 日志时,出现以下错误:

[Mon Nov 25 15:57:08 2013] [error] [client 127.0.0.1] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

这里发生了什么?

【问题讨论】:

  • redirect("")?重定向到自己?所以你发布到一个脚本,该脚本重定向到自己,没有上传完成,所以它再次重定向到自己,等等......?
  • 不,不是,它会重定向到base_url!

标签: php apache file-upload internal-server-error


【解决方案1】:

也许您应该致电redirect("/");redirect(base_url().'adminpanel/');

或者将此重定向移动到 if (!empty($_FILES)) 的花括号中。

【讨论】:

猜你喜欢
  • 2017-02-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-11
  • 2015-10-11
相关资源
最近更新 更多