Memory exhausted using php: // input

When using fopen ("php: // input") to download a file with 120 MB, we get a warning "out of memory" from php. For php memory_limit is set to 256 MB, and we have enough memory.

We removed all the code except fopen ("php: // input") and it still does not work, so the error should be there.

We tried different memory limits and about 500 MB the error disappears. However, we really should not use 500 MB, so the question remains: why do we get an exhausted memory error using fopen in a file size of 115-120 MB.

Our php test file:

<?php $inputHandler = fopen('php://input', "r"); ?> 

And the error:

 262144000 bytes exhausted (tried to allocate 120829495 bytes) 

I hope someone can help us. This is driving us crazy!

Thanks in advance!

+4
source share
2 answers

Try setting up unlimited memory usage:

 ini_set('memory_limit', '-1'); 
0
source

This may be due to php trying to automatically parse the POST data. To disable this, in php version 5.4+ you can set enable_post_data_reading to 0. (for this purpose I used .htaccess) But, in fact, in php 5.4+ it is better to use $ _FILES to load ...

0
source

Source: https://habr.com/ru/post/1492956/


All Articles