File size and upload limits

InfinityFree has two kinds of size limits:

  • The PHP upload limit, for files uploaded through your website.
  • The file size limits, for the files on your account.

Both limits are fixed and cannot be increased.

PHP upload limit: 20 MB

Files uploaded through your website, like images in the WordPress media library or attachments in a form, can be up to 20 MB.

If you try to upload a larger file, you’ll see an error like:

  • The uploaded file exceeds the upload_max_filesize directive in php.ini.
  • In WordPress: [file name] exceeds the maximum upload size for this site.

File size limits

The maximum size of a file on your account depends on the file type:

File type Size limit
HTML, PHP and JS files 1 MB
.htaccess files 10 kB
All other files 10 MB

If you upload a file larger than this limit, it will be deleted automatically. The upload may seem to complete normally, but the file will be gone right after.

These limits are more than enough for regular website files. If you have a file that exceeds them, see the tips below.

Uploading large archives, plugins and themes

If you want to upload a script, plugin or theme that’s larger than the limit, see How to upload big files/archives for workarounds.

Hosting videos and large downloads

InfinityFree is not suited for hosting video files or large downloadable files. Please use a specialized service for those, like YouTube for videos or Google Drive for downloads, and link to it or embed it on your website.

Making HTML, PHP and JS files smaller

Depending on the contents of the file, you may be able to make it smaller in one of these ways:

  • Move CSS and JavaScript code to separate files and link them from the page. This also makes your website faster, because browsers can cache separate files.
  • Move large amounts of data to separate text files, or to a MySQL or SQLite database you query from PHP.
  • Split large PHP files into multiple files and combine them with include or require. This also makes your code easier to reuse and read.
  • Split large HTML pages into reusable parts, like headers and footers, and combine them with PHP include or require. If the page itself contains a lot of content, consider spreading it over multiple pages. Very large pages are slow to load and use a lot of data, especially for mobile visitors.

Making other files smaller

  • Text files: split the text across multiple files, and serve them separately or combine them with PHP.
  • Images, audio and video: use a more efficient format (like MP3 instead of WAV) or stronger compression. You can also host them on a specialized photo, music or video service and link to it from your website.

Making .htaccess files smaller

Large .htaccess files slow down your website and the websites of others on the same server, so you should avoid them in general. Below are common reasons for large .htaccess files and better alternatives.

Blocking bad bots

Blocking bots by their user agent is of limited use:

  • Bots can send any user agent they want, and many pretend to be regular browsers.
  • Free hosting already has a security system that keeps out bots, which works better than a user agent filter.

You can safely remove these rules.

Blocking or allowing countries

Country restrictions with IP ranges in .htaccess are unreliable. IP ranges belong to network operators, who can use them anywhere, so no list of IP ranges per country is ever fully accurate.

Instead, you can move the IP filtering to your PHP code. From PHP, you can also use a GeoIP service for more accurate location data, and show blocked visitors a custom page instead of a generic “403 Forbidden” error.

Many rewrite rules

If you’ve written your own software, routing every URL with its own rewrite rule can make your .htaccess file grow quickly.

Most frameworks and CMSes handle routing in PHP instead. All requests are sent to a single index.php file, and the PHP code decides which page to show based on the URL. This keeps your .htaccess file small, no matter how big your website gets.

1 Like

I think the article may need to be updated with this information:

This in particular could be misleading:

6 Likes

Good catch. Updated!

5 Likes

Nice! I still think the information about HTML/PHP and .htaccess files should be included in this article as well, as this is the first result that comes for “file size limit”.

4 Likes