【发布时间】:2017-01-16 12:45:50
【问题描述】:
我似乎在CodeIgniter 中上传文件时遇到问题,导致标题中出现错误。我在不同网站上的同一台服务器上进行文件上传,这就是为什么我认为相同的代码可以用于此上传。我第二次尝试upload时出现问题。
这是我目前在controller 中使用的代码
public function bulk_product_upload_file()
{
$location_of_bulk_product_files = LOCATION OF FOLDER;
if ($this->is_post()):
if (is_uploaded_file($_FILES['userfile']['tmp_name'])):
$date_for_file = date("dmyHis");
$config['upload_path'] = $location_of_bulk_product_files; //upload directory
$config['allowed_types'] = 'xlsx'; // allowed file types
$config['max_size'] = '100';
$config['overwrite'] = TRUE;
$config['remove_space'] = TRUE;
$config['file_name'] = $date_for_file;
$this->load->library('upload', $config);
if($this->upload->do_upload()):
// I have also tried if($this->upload->do_upload('userfile')): that resulted in the same error
// file upload success
else:
// file upload failed
endif;
else:
$this->session->set_flashdata('message_error','Please select a file to upload.');
redirect('main/create_bulk_product');
endif;
else:
$this->session->set_flashdata('message_error','Sorry! Somthing went wrong, please try again.');
redirect('main/create_bulk_product');
endif;
}
我收到的error:
HTTP Error 500.0 - Internal Server Error
The page cannot be displayed because an internal server error has occurred.
Module FastCgiModule
Notification ExecuteRequestHandler
Handler PHP
Error Code 0x00000000
我更感到困惑的是,它正在同一服务器上的另一个网站上运行,但不是这个。所有设置似乎也完全相同。任何帮助将不胜感激。
【问题讨论】:
-
您的代码看起来不错...您可以通过逐步添加断点来测试此问题...
-
同时发布您的 .log 文件。你可以在那里找到错误
-
@chhameed 我该怎么做(添加断点)?我认为这可能与我的 Codeigniter 版本有关,因为新网站使用的是更新版本。
-
你的日志文件是怎么说的?
-
原来我使用的 CodeIgniter 版本的上传库有问题。使用新的 upload.php 文件解决了问题。
标签: php codeigniter iis