WebFileMan Configuration & Using

PHP Out Of Memory Error

When trying to use the Zip & Download option on bigger files or folders, the following or similar error appears:

***Fatal error*: Out of memory (allocated 40894464) (tried to allocate 15800793 bytes) in */some-php-file-here.php*


The WebFileMan script creates a zip file on-the-fly and in case of big files it requires quite some server memory. By default PHP scripts are allocated a little bit scarce memory resource, but fortunately, we can extend it.

We need to increase 2 settings:


memory_limit sets the amount of server memory available for the PHP script.


This zip job would require pretty long time so we suggest that this setting should also be extended.

Now the question is where you should put these settings in?

Updating The Main PHP php.ini Configuration File

If you own the web server or rent a dedicated server, the best way is to place them in the main PHP configuration file - the php.ini file. You can easily find out the path of this file if you create a test PHP page with phpinfo(); function - it will show the path to the php.ini file. The code that you enter in this file may look as follows:

max_execution_time = 600
memory_limit = "128M"

Please note that these values are for example only, you might need to experiment with different figures depending on your requirements. Just make sure that you overwrite the original settings that already present in the php.ini.

Using Subdirectory .htaccess File

If you rent a shared hosting, the situation may be a bit more complicated. You can change the PHP settings if your web hosting accoint meets all the following requirements:

  • The web server software is Apache
  • The PHP is installed as an Apache module (not CGI)
  • You are allowed to alter the PHP configuration by using sub-directory .htaccess files

You should ask all these questions to your web hosting system administrator, and if all replies are "Yes", you are lucky today.

Create a new file named ".htaccess" in the home folder of your PHP script and enter the following code there:

<IfModule mod_php5.c>
	php_value max_execution_time 600
	php_value memory_limit "128M"
<IfModule mod_php4.c>

	php_value max_execution_time 600
	php_value memory_limit "128M"


Testing Your Updated Configuration

You can see if your updated settings come in force if you open up again that test PHP page with phpinfo(), search for these parameters and you should see the updated values.