Issues

ZF-5703: Unnessesary Fatal Error: when post_max_size exceeds memory_limit setting

Description

I'm trying to use my own upload Zend_Form class with a file element and (setMaxFileSize) to auto create the hidden MAX_FILE_SIZE field. Using this class in my app gives a Fatal Error: Your 'post_max_size' config settings exceeds the 'memory_limit' setting. You should fix this.

Well, for many years I'm handling file uploads with php and never ever used more than a 128MB max_mem_size, even with 1Gb wire speed uploads I'm using 64MB max. The php settings affected to successfully upload files are in my believe:

  • upload_max_filesize
  • post_max_size
  • max_input_time

When the HTTP POST is successfully received and the php script starts doing funny things like copy, rename, etc the max_execution_time comes in. IF there are scenario's the memory_limit should be set at at least the post_max_size, could you please make this a Notice, instead of a Fatal error. Currently I've to set insane memory_limit values to accept 1GB form uploads or create the hidden field manually.

Comments

When your memory settings are lower than your post filesize settings than you are not able to receive files which exceed the memory limit, as the posted data can not be received.

You can read this within PHP's manual within the php.ini directives: {quote} Generally speaking, memory_limit should be larger than post_max_size. {quote}

And when you switch off the memory limit (-1) then you will also not get an error triggered.

Changed with r13999