Php 不允许CodeIgniter文件上载
我正在CodeIgniter中设置一个上传表单。我已将allowed_types参数设置为:Php 不允许CodeIgniter文件上载,php,codeigniter,Php,Codeigniter,我正在CodeIgniter中设置一个上传表单。我已将allowed_types参数设置为: $config['allowed_types'] = 'xls|xlsx'; 并在config/mimes.php中添加了以下行: 'xls' => array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'), 'xlsx' => 'application/vnd.openxmlf
$config['allowed_types'] = 'xls|xlsx';
并在config/mimes.php中添加了以下行:
'xls' => array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'),
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
然而,尽管我试图上传的文件是xlsx文件,CI仍然告诉我该文件类型是不允许的。有什么想法吗
public function do_upload() {
// Change this if you change the upload directory
$upload_path = "/webusers/ad6vcf/public_html/funding_manager/application/uploads";
$config['upload_path'] = $upload_path;
//At some point will add support for csv
$config['allowed_types'] = 'xls|xlsx';
//Max 5000kb please
$config['max_size'] = '5000';
$this->load->library('upload', $config);
$this->upload->initialize($config);
if (!$this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->upload($error);
} else {
$upload_data = $this->upload->data();
bulk_insert($upload_path . $upload_data['file_name']);
}
}
请试试这个
$this->load->library'upload',$config;
$this->upload->initialize$config 你试过这个吗
if (!$this->upload->do_upload('put the name of the input field here'))
你为什么评论这行/$config['allowed_types']='xls | xlsx';这是一个错误,现在取消了注释,但仍然得到相同的errorapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet请将其作为mime类型尝试xlsx@VaisakhPc完成后,我用新代码更新了我的问题,但仍然不起作用:'xlsx'=>array'application/vnd.openxmlformats officedocument.spreadsheetml.sheet',“application/zip”。首先尝试xls,然后尝试xlxs。如果两者都有错误,请将“xlsx”=>array”application/vnd.openxmlformats of icedocument.spreadsheetml.sheet、“application/zip”放在XLX上,然后尝试输入相同的错误。我试图上载的文件:01\usrt11\ROF\max\ManW7\Desktop\universions hr contact.xlsx检查$\u文件['input\u file\u name']['type']上的类型,并将其添加到mime.phpLet us中。