Why are my files deleted after uploading them?
Sometimes, when you upload a file, the upload is completed but the file is deleted immediately afterwards. This is usually caused by one of the following issues:
The file is not in a htdocs folder
All websites files must be uploaded to either the main
htdocs folder, or to the domain specific
htdocs folder (like
example.com/htdocs). If a file is created or uploaded anywhere else, it will be deleted automatically.
The file type is not allowed
Certain file types, like
.exe files, are blocked on InfinityFree for security and fair usage limitations. Regular website files are allowed, but other files may be blocked. So if you would like to offer something for download or embed a video in your website, please use a specialized file sharing service or video streaming service for that instead.
The file contains malware
Uploaded files are automatically scanned for malware. If malware is detected in a file, it’s automatically deleted to prevent damage to your website and your visitors.
The file is bigger than 10 MB
There is a file size limit of 10 MB on our servers. If you try to upload a file bigger than 10 MB to your account, it will be deleted.
Please note that this is a file size limit, not just a PHP upload limit. All files on your account are subject to this limit, regardless of the particular file has been added to your account.
If this is the problem you experience, please see the article How to upload big files for workarounds.
The file is a .htaccess file larger than 10 kB
In addition to the general file size limit, there is a limit of 10 kB for .htaccess files. A .htaccess file larger than 10 kB will automatically be deleted.
The most common reason for having huge .htaccess files is a large set of IP address blacklisting or whitelisting rules. If you would like to block or allow specific countries to access your website, you can use PHP code to filter IP addresses, or even use a GeoIP service, to enforce the restrictions instead. And unlike with .htaccess rules, you can even display a notice to let people know about the blocks.
The file is a HTML or PHP file larger than 1 MB
In addition to the general file size limit, there is a limit of 1 MB for HTML and PHP files. Any HTML or PHP code file larger than this will automatically be deleted after uploading it.
Depending on the contents of your PHP/HTML file, you may be able to reduce the file size in one of the following ways:
- If the HTML page contains a lot of data to be displayed to visitors, you may be able to move this data to separate text files or a MySQL or SQLite database which can be queried from PHP.
- If the file contains a lot of PHP code, you may be able to move some of this code to separate files, and use PHP
requiredirectives to combine the code in a single process. This also makes it easier to reuse code across multiple pages, and generally makes it easier to read and understand.
- If the file contains a lot of HTML code, you can also use PHP
requiredirectives to combine multiple HTML files, like headers and footers, into a single page. However, note that having a very large HTML page means it may be very slow to load for people and use a lot of bandwidth, which is bad for (mobile) users. So you may also wish to consider to restructure your website so spread the content over multiple, specific pages.