脚本宝典收集整理的这篇文章主要介绍了php – CodeIgniter“不允许您尝试上传的文件类型.”,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在遵循此CI指南来构建我的代码:http://codeigniter.com/user_guide/libraries/file_uploading.html
这是我得到的:
查看文件:
[..] <?= form_oPEn_multipart() ?> <input type="file" name="userfile" size="20" /> <br /><br /> <input type="submIT" value="upload" /> <?= form_close() ?> [..]
我的控制器:
$config['upload_path'] = './uploads/'; $config['Allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '100'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $this->load->library('upload',$config); $xx = array('upload_data' => $this->upload->data()); $mimetype= $xx['upload_data']['file_type']; var_dump('Mime: ' . $mimetype); VAR_dump($_FILES); if ( !$this->upload->do_upload()) { Notice::add($this->upload->display_errors(),'error'); } else { $data['upload_data'] = $this->upload->data(); }
正如你所看到的,我正在尝试var_dump MIME类型,结果为空.
当我做var_dump($_ FILES)时,看起来一切都很好:
array(1) { ["userfile"]=> array(5) { ["name"]=> string(14) "imageofm.png" ["type"]=> string(9) "image/png" ["tmp_name"]=> string(18) "/var/tmp/PHP5cDAZJ" ["error"]=> int(0) ["size"]=> int(358) } }
另外,我得到’png’=>数组(‘image / png’,’image / x-png’),line,在我的config / mimes.PHP中.
但是,它确实发生在所有图像上(还没有尝试过其他扩展).
我很感激每一次尝试.
'csv' => array('application/vnd.ms-excel','text/anytext','text/plain','text/x-comma-separated-values','text/comma-separated-values','application/octet-stream','application/vnd.ms-excel','application/x-csv','text/x-csv','text/csv','application/csv','application/excel','application/vnd.msexcel')
以上是脚本宝典为你收集整理的php – CodeIgniter“不允许您尝试上传的文件类型.”全部内容,希望文章能够帮你解决php – CodeIgniter“不允许您尝试上传的文件类型.”所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。