dongtiao2066 2017-11-01 11:18 采纳率: 0%
浏览 47

如何使用codeigniter上传超过2mb的文件

I am trying uploading a file which is more than 2mb even after setting maximum size in controller but still the file is not getting uploaded.please help to find the solution for this problem.

Below is my code:

Controller

    $config['upload_path'] = './abc/';
    $config['allowed_types'] = '*';
    $config['max_filename'] = '255';
    $config['encrypt_name'] = FALSE;
    $config['overwrite'] = TRUE;
    //$config['max_size'] = '102400'; //100 MB
    $config['max_size']             = '25600';
    $config['max_width']            = '0';
    $config['max_height']           = '0';
    $config['file_name']=$newfilename;
  • 写回答

2条回答 默认 最新

  • doupinge9055 2017-11-01 11:33
    关注

    The size limitation is imposed by your PHP configuration also; therefore you need to update php.ini and update two settings post_max_size and upload_max_filesize.

    The php.ini is not found on codeigniter, rather the PHP installation on your server. Read more about it here: http://php.net/manual/en/configuration.file.php

    Say you want to allow a max upload file size of 256mb, this is what you should have on the php.ini:

    post_max_size=256M
    upload_max_filesize=256M
    

    Once you made the change to php.ini, you have to restart the apache or php-fpm - depending on what you are using.

    If you are on a shared hosting environment, you may not get direct access to the php.ini file, but your hosting provider may give you limited access to modify php configuration via their hosting control panel such as cPanel or Plesk etc...

    If you developing locally, and say you are on windows using XAMPP for example; the php.ini file is usually found here: C:\xampp\php\php.ini (depends on where you've installed xampp). On linux, the php.ini configuration tends to be somewhere like /etc/php.ini (not always guranteed).

    You could always create a file on your server called phpinfo.php with this script: <?php phpinfo(); ?> and visit it, e.g. http://localhost/phpinfo.php and it will show you the location the loaded php.ini file as well as the current setting values of post_max_size and upload_max_filesize.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题