Category: Uncategorized

  • PHP.ini settings to upload a large image

    I have a PHP web app running on a shared Ubuntu server that uploads images to Amazon S3 storage. On a mobile phone the camera can be used to upload a photo directly.

    All worked fine until someone upgraded the version of PHP and the uploads stop working.

    It turns out that this had reset the PHP file upload settings to their defaults, giving a max upload size of 2Mb which was too small for photos taken on the mobile phone.

    The fix, with some help from ChatGTP , was to update the following php.ini file settings

    ; Maximum allowed size for uploaded files.
    ; http://php.net/upload-max-filesize
    upload_max_filesize = 256M
    
    ; Maximum size of POST data (must be equal or larger than upload_max_filesize)
    ; http://php.net/post-max-size
    post_max_size = 280M
    
    ; Max execution time for scripts (seconds)
    ; http://php.net/max-execution-time
    max_execution_time = 90
    
    ; Optional: Max input time for parsing data (seconds)
    max_input_time = 60
    

    and also update the Apache config (i.e. /etc/apache2/sites-available/000-default.conf), setting LimitRequestBody in the <Directory> block to an appropriate size for the bytes allowed in the request body.

            <Directory /var/www/xxx>
                ...
                LimitRequestBody 268435456
            </Directory>

    An apache restart got the uploads working again

    sudo systemctl restart apache2

    Being on a shared server I also updated the .htaccess file just in case there was a later need for the server settings to be changed.

    php_value upload_max_filesize 256M
    php_value post_max_size 272M
    php_value max_execution_time 90
    php_value max_input_time 90
    php_value memory_limit 384M

    The settings in the .htaccess file override the php.ini settings when using Apache + mod_php.

  • How cats choose a Domain Name

    Thinking …

    Thinking …

    Done …

  • Hello world!

    Welcome to WordPress. This is your first post. Edit or delete it, then start writing!