Upload_max_filesize trong tập tin php.ini

  -  

Trying to lớn upload something to your WordPress site only to be met with a message saying “the uploaded file exceeds the upload_max_fileform size directive sầu in php.ini”?


This error message can appear when you’re uploading large images, videos, plugins, themes, any type of tệp tin that you upload to lớn your WordPress site.

Bạn đang xem: Upload_max_filesize trong tập tin php.ini

In this article, we’re going khổng lồ help you fix the problem và make it so that you can upload those large files. In total, we’ll cover:

What Causes the uploaded tệp tin exceeds the upload_max_fileform size directive sầu in php.ini


*

An example of the uploaded file exceeds the upload_max_filekích cỡ directive in php.ini


Let’s start at the beginning. In order khổng lồ preserve your server’s resources, hosts mix a limit on the maximum kích cỡ of a file that can be uploaded.

This maximum, in megabytes, is defined in the upload_max_filesize directive sầu.

The upload_max_filesize directive itself is located in the php.ini tệp tin, which is the default VPS configuration file for applications that require PHP..

Those two things – upload_max_filesize & php.ini – are what the error message you see is referencing.

It’s important to rethành viên that this upload limit is not a WordPress setting. However, you can see this limit in your WordPress site if you go lớn Media → Add New:


*

How to check upload limit in WordPress


As you can see above, hostingvietnam.vn sets the default limit at 128 MB, which is quite large và unlikely to lớn ever cause issues. However, a lot of other hosts mix the default as small as just 2 MB or 4 MB.

That means if you try to upload a tệp tin larger than that limit, you’re going lớn see the “the uploaded tệp tin exceeds the upload_max_fileform size directive in php.ini”, or a similar message lượt thích “file_name exceeds the maximum upload size for this site.”

How to Fix the uploaded file exceeds the upload_max_filesize directive in php.ini

In order to fix this error, you need to lớn increase the tệp tin kích cỡ upload limit. That is, you need to lớn increase the value of the upload_max_filesize directive in your php.ini tệp tin.

There are several different ways you can bởi vì this – the exact method that you choose will depkết thúc on your preference and your host’s configuration.

1. Talk to lớn your host’s support

While we’ll cover some methods that you can try by yourself, the simplest solution is usually to lớn just reach out to your host’s support and ask them to lớn increase the limit for you.

This is a comtháng request, your host’s tư vấn should know exactly what you want, and it should only take a couple of minutes of your time. That’s what your host’s tư vấn is there for!

If you host at hostingvietnam.vn and need khổng lồ increase your limit beyond the default 128 MB limit, you can reach out to support on Intercom from anywhere in your hostingvietnam.vn dashboard:


*

WordPress host support


2. Edit php.ini via cPanel

If your host uses cPanel, you should be able to edit your php.ini file & upload_max_filesize directive via the cPanel dashboard.

First, look for the MultiPHP.. INI Editor:


*

The MultiPHPhường. INI Editor in cPanel


Then choose your WordPress site from the drop-down. After that, you’ll be able to lớn edit the upload_max_filesize directive sầu for that site:


*

Changing the upload_max_fileform size directive sầu in cPanel


Increase the value based on your needs.


Sign Up For the Newsletter


3. Create or edit php.ini via FTP

As you learned above sầu, the php.ini file controls how your hệ thống works for PHP applications.

Xem thêm: Hướng Dẫn Kiếm Tiền Trên Facebook Có Thật Không, Bí Mật 2021

Unfortunately, based on your host’s restrictions, you may or may not be able to use php.ini files. For that reason, a more reliable approach can sometimes be to lớn use .htaccess (which we’ll cover in the next section).

However, you can give sầu this a try first to see if you are allowed lớn use php.ini at your host.

To get started, connect khổng lồ your hệ thống via FTPhường and go to your site’s root folder.

If you already see a php.ini tệp tin in the root folder, you can edit that tệp tin. Otherwise, create a new file and name it php.ini:


*

How khổng lồ create a new php.ini file


Then add or modify the code snippet below:


*

Adding the code khổng lồ the php.ini file


Some hosts might further require you to add the suPHP directive in your site’s .htaccess tệp tin in order for the changes above sầu lớn actually work.

To vị this, you can also edit your .htaccess file via PHPhường & add the following code near the top of the file:

suPHP_ConfigPath /home/yourusername/public_html

Make sure khổng lồ replace yourusername with the actual file path of your site.

4. Increase upload_max_filekích cỡ value by editing .htaccess

If directly creating or editing the php.ini tệp tin via the methods above didn’t work, you can also try to modify the upload_max_filesize directive by editing your site’s .htaccess tệp tin.

To get started, connect lớn your site via FTPhường. and edit the .htaccess tệp tin that’s located in your site’s root thư mục.

Then, add the following code snippet, making sure lớn adjust the values based on your needs:

php_value upload_max_filesize 12Mphp_value post_max_kích thước 13Mphp_value memory_limit 15M


*

How to lớn control php.ini file via .htaccess


If you get an internal hệ thống error message after adding this code snippet, your server is likely running PHP in CGI mode, which means you cannot use these commands in your .htaccess tệp tin. Remove the snippets you just added & your site should start functioning again.

lưu ý – if you’re a hostingvietnam.vn customer, hostingvietnam.vn uses NGINX, which means your site does not have sầu an .htaccess file. If you need help at hostingvietnam.vn, we recommover just reaching out lớn our tư vấn team and they’ll be able to lớn quickly get things working for you.

Summary

To kiểm tra if your changes are working, you can go baông chồng to lớn Media → Add New in your WordPress dashboard to see if the new maximum upload limit matches the number you set in your php.ini file. If all goes well, you should see your new value & you’ll be able to upload the tệp tin that was giving you problems.

Xem thêm: Phần Mềm Kế Toán Asia Soft, Phần Mềm Kế Toán Asia Accounting

Finally, if nothing you’ve tried is working and your host’s support can’t help for some reason, you can always upload the file via FTP as a workaround. FTPhường has no limits và will let you upload everything from images to lớn plugins & themes. You can even bulk upload files if needed.


If you enjoyed this tutorial, then you’ll love sầu our support. All hostingvietnam.vn’s hosting plans include 24/7 tư vấn from our veteran WordPress developers and engineers. Chat with the same team that backs our Fortune 500 clients. Cheông xã out our plans