【发布时间】:2012-07-05 22:07:45
【问题描述】:
以前有人问过这个问题,但不是针对这个确切的问题。 我有一个很好的上传系统(我正在上传 CSV 并解析它们)。 但是,如果文件大小超过 5Mb,则会出现错误: 您没有选择要上传的文件
如果是under,文件上传解析就好了。
我已将我的 php.ini 设置首先设置为 128M,现在设置为 99999999999999999999 我还将 CI 配置 maz_size 设置为 9999999999 (我使用的是更真实的数字,但我想确定一下) 每次更改 ini 时我都重新启动了 apache,但问题仍然存在。
我看到了错误: 您没有选择要上传的文件 当存在文件大小问题但我不知道在哪里检查时显示。
最后,如果我 echo phpinfo(),我可以确认最大上传是 999999999999999
拔掉我的头发……
还能是什么?
/// 更新:代码添加 我有两种解析 csv 的方法,可以是逐行解析,也可以将整个文件直接转储到数据库中,然后再进行整理。这两项工作,并由配置设置选择。这就是这行: $this->config->item('import_type') 的用途。欢迎任何想法!
public function upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'txt|csv|xls|xlsx';
$config['max_size'] = '999999999999999999999';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('feed_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
if ($this->config->item('import_type') == 'db') {
$result = $this->model_feed->capture_file($this->input->post('feed_name'), $data['upload_data']['full_path']);
} else {
$result = $this->capture_feeds($this->input->post('feed_name'), $data['upload_data']['full_path']);
}
if ($result) {
$this->load->view('feed_upload_success', $data);
} else {
$this->load->view('feed_form', array('error' => 'The file you supplied does not match the data structure we were expecting.' ));
}
}
}
【问题讨论】:
-
您是否将表单设置为多部分?
-
你能粘贴你的代码吗?可能有错别字或错误
标签: codeigniter upload codeigniter-2 filesize