Codeigniter:不允许您尝试上传的文件类型 [英] Codeigniter: The filetype you are attempting to upload is not allowed

查看:38
本文介绍了Codeigniter:不允许您尝试上传的文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CI最新版本。 上传JPG文件时出错。我从这里使用代码 https://www.codeigniter.com/userguide3/libraries/ file_uploading.html 从Codeigniter上传的多个文件

I'm using CI latest version. Got error while uploading a JPG files. I use the code from here https://www.codeigniter.com/userguide3/libraries/file_uploading.html and a little bit from Multiple files upload in Codeigniter

控制器

$config = array(
'upload_path'   => 'path to upload',
'allowed_types' => 'jpg|gif|png|jpeg',
'overwrite'     => 0,
'max_size'      => 1024,                       
);
$this->load->library('upload', $config);
$this->upload->initialize($config); // Make sure it has been initialized

if (!$this->upload->do_upload('gambar1')){
    $error = array('error' => $this->upload->display_errors());
    return $error;
}else{ echo 'success'; }

视图

<?php echo form_open(base_url().'report/send', 'method="post" enctype="multipart/form-data"', $hidden);?>
<input type="file" class="hidden" name="gambar1"></form>

当我尝试上传JPG文件时,它会给我您尝试的文件类型不允许上传。
有任何想法吗?

When I'm trying to upload JPG files, it gives me The filetype you are attempting to upload is not allowed. Any idea?

推荐答案

解决方案:
我尝试将其上传到服务器。但这仍然给我同样的错误。然后我发现了这个: Codeigniter:不允许您尝试上传的文件类型。昨天很好
最近一次是我将核心Codeiginter版本从2.x升级到3.x的。我更新了系统目录的内容,但没有更新应用程序的内容/ config。我没有发现application / config / mimes.php文件稍有不同的事实-新版本返回一个数组,而旧版本将其包含为变量。较新版本的mimes.php

这篇关于Codeigniter:不允许您尝试上传的文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆