Increase upload file size limit in PHP
Try uploading smaller files
If you are experiencing difficulties uploading even small file sizes, it indicates a general problem with the uploading process. First, check the PHP error logs for any relevant error messages. Additionally, make sure that you have sufficient disk space available. In Linux, you can use the following command to check the available disk space:
df -h
By examining these aspects, you can identify and address the underlying issues affecting your file uploads.
If you're able to upload smaller files successfully, but not larger ones, there are a few steps you can take to troubleshoot the issue.
Check your PHP configuration settings
There are directives that determine the maximum size of data that can be uploaded to a server.
upload_max_filesize
sets the limit on the size of each individual file that can be uploaded.post_max_size
sets the limit on the total size of the entire upload request.
Verify that these PHP settings are large enough to accommodate the size of the files you're trying to upload.
The default value for these settings is 2M
. If you use the default limits, you'll need to increase them in your PHP configuration file (php.ini
):
Where can I find php.ini
?
The location of the php.ini
file varies depending on your server configuration and operating system. Here are some common locations where you might find the file:
On Linux systems running Apache, the
php.ini
file is typically located in/etc/php/
.On Windows systems running Apache, the
php.ini
file is typically located in the Apache installation directory, such asC:\Program Files (x86)\Apache Group\Apache2\
.On Windows systems running IIS, the
php.ini
file is typically located in the PHP installation directory, such asC:\PHP\
.
If you're not sure where to find the php.ini
file on your server, you can create a new PHP script with the following code:
<?php
phpinfo();
?>
This script will output a table of information about your PHP configuration, including the location of the php.ini
file. Look for the "Loaded Configuration File" entry to find the path to your php.ini file.
Check your web server settings
You can also check server settings, such as the max_execution_time
and memory_limit
. Ensure that the settings values are sufficient for the file size you're trying to upload.