I can’t upload an image more than 2MB in my website form.
I have set up the needed settings in /etc/php/7.4/fpm/php.ini
:
; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size = 100M
.
.
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
; Whether to allow HTTP file uploads.
; http://php.net/file-uploads
file_uploads = ON
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://php.net/upload-tmp-dir
;upload_tmp_dir =
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 100M
; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20
.
.
; Maximum amount of memory a script may consume
; http://php.net/memory-limit
memory_limit = 128M
But the problem is that when I print php info in my index page I get different output :/
Why is this happening and how can I fix it?
NOTE: I’m serving my website with nginx if it matters (see nginx settings)
3
Answers
Finally issue fixed:
the solution was to add
php.ini
and.user.ini
files in the project's public directory to set the needed values (both files):like this:
I didn't find the real reason why updating
/etc/php/7.4/fpm/php.ini
but these 2 files finally fixed itTwo PHP configuration options control the maximum upload size:
upload_max_filesize
andpost_max_size
. If you’re going to increase those significantly, consider upping themax_input_time
andmax_execution_time
values as wellIf you can’t find the source of the 2mb setting in php.ini you can override in a .htaccess file
Or directly in your PHP pages if need be
for example…
If Upper answers not fixed then try below steps:
user.ini
file into additional ini file loaded location – seephpInfo()
to find the location path. (search keyword- Additional .ini files)max_upload_size = 20M