gpt4 book ai didi

codeigniter - codeigniter 中的上传大小限制

转载 作者:行者123 更新时间:2023-12-04 00:43:24 29 4
gpt4 key购买 nike

我有一个用户可以注册的页面。他在此过程中上传了个人资料照片。我想限制大小,但除了 $config['maxsize'] 之外,并没有太多强调 codeigniter 文档。我尝试了以下但我没有收到任何消息。我将大小设置为 10 (KB) 只是为了测试。我是否必须以某种方式处理它才能将消息传达给我的观点?

public function add_user()
{


$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '10';
//$config['max_width'] = '1024';
//$config['max_height'] = '768';

$this->load->library('upload', $config);
$fullImagePath;
if (isset($_FILES['userfile']) && !empty($_FILES['userfile']['name']))
{
if ($this->upload->do_upload('userfile'))
{
// set a $_POST value for 'image' that we can use later
...

顺便说一句,这段代码在我的模型中。

最佳答案

@Chetan Wadhwa,

您确定大小以字节为单位(不是以 KB 为单位)。请参阅 codeigniter 文档:http://www.codeigniter.com/user_guide/libraries/file_uploading.html , 必须以 KB 为单位。

关于codeigniter - codeigniter 中的上传大小限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16208096/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com