Small file get uploaded but not large file in Laravel

后端 未结 6 1514
無奈伤痛
無奈伤痛 2020-12-09 09:28

I have this action in controler

    public function upload() {
  // getting all of the post data
  $file = array(\'image\' => Input::file(\'image\'));
  /         


        
相关标签:
6条回答
  • 2020-12-09 09:50

    For laravel apps running on nginx..

    1. Identify your php ini file:

      php -i | grep php.ini

    2. Edit both the cli and the fpm files to be sure:

      vim /etc/php/7.2/cli/php.ini

      vim /etc/php/7.2/fpm/php.ini

    3. Change these to your prefered limits:

      post_max_size = 1G

      upload_max_filesize = 1G

      memory_limit = 1G

    4. Restart php fpm

      service php7.2-fpm restart

    5. Reload nginx

      service nginx reload

    0 讨论(0)
  • 2020-12-09 09:59

    Check max_file_uploads and max_post_size in php.ini. It shows from phpinfo()

    0 讨论(0)
  • 2020-12-09 10:03

    Other answers refers saying only about the php.ini directiress.

    I would like to give answer considering both php.ini and the Laravel Validation Rule

    First check your php.ini

    For the upload_max_filesize and post_max_size and change to your desired file size

    upload_max_filesize = 100M
    post_max_size = 100M
    

    You shall have your rule like this

    public static $updaterules = array(
        'uploadedimage' => 'image|max:5000'            
        );
    

    Additional information :

    You shall check for the file format for image by

    'uploaded' => 'mimes:jpeg,bmp,png'
    

    Read more about Laravel validation here

    Update :

    As the questioner didn't noticed which php.ini file is being used by the server. I am updating my answer accordingly so it might be useful for someone who has similar problems in future

    To find the full configuration about the php.ini file which is currently being used by your server.

    For Linux

    php -i | grep php.ini
    

    For Windows

    php -i | find /i "Configuration File"
    

    From a php file

    i.e.,

    <?php
    phpinfo();
    ?>
    
    0 讨论(0)
  • 2020-12-09 10:08

    Well I found the answer, The things mentioned above to make change in php.ini about upload_max_filesize and post_max_size are infact the only thing to solve the problem mentioned by the question.

    The only problem was that I am using wamp and apparently wamp has multiple php.ini files one in php folder and one in apache folder. I made changes in PHP folder when the change should be made to the one inside apache folder.

    0 讨论(0)
  • 2020-12-09 10:15

    edit your php.ini file and set:

    memory_limit = 32M
    upload_max_filesize = 70M
    post_max_size = 100M
    

    and restart apache.

    0 讨论(0)
  • 2020-12-09 10:16

    FOR WAMP SERVER: Go to /wamp64/bin/apache/apache(your version)/bin/ and open php.symlink(.ini) and change
    post_max_size,memory_limit,upload_max_filesize as per your need. and restart the wamp server.

    0 讨论(0)
提交回复
热议问题