雷林鹏分享:CodeIgniter文件上传错误:the filetype you are attempting to upload is not allowed

  CodeIgniter文件上传错误:the filetype you are attempting to upload is not allowed

  在本地lnmp测试环境文件上传成功,代码移至到生成环境后,提示 the filetype you are attempting to upload is not allowed 错误,谷歌了N久才找到解决方法。

  网络上有说出现 the filetype you are attempting to upload is not allowed 错误的可能原因:

  1、重命名导致,去除重命名配置项

  2、重名不带后缀

  .....

  最终解决方法:

  修改前:

  $config['allowed_types'] = 'jpg|gif|png|jpeg|bmp';

  修改后:

  $config['allowed_types'] = '*';

  最终上传配置项:

  $config['upload_path'] = $save_path;

  $config['allowed_types'] = '*';

  $config['file_name'] = "{$userid}.png";

  $config['overwrite'] = true;

  $this->load->library('upload', $config);

  通过把允许上传类型改为 * ,这样可能会存在一些安全问题。

  文章转载自 [http://www.php230.com]

  (编辑:雷林鹏 来源:网络 侵删)

猜你喜欢

转载自www.cnblogs.com/linpeng1/p/10819367.html