Nazeer Shaik
Nazeer Shaik

Reputation: 65

PHP file_get_contents giving out of memory issue for more than 20 MB pdf files

ini_set('memory_limit', '-1');
ini_set('post_max_size','-1');
ini_set('upload_max_filesize','-1');
ini_set('max_execution_time','0');
set_time_limit(0);

$files = file_get_contents($_FILES['file']['tmp_name']);
$file_base = base64_encode($files);

The above code working fine with files smaller than 20 MB. But when i try to upload pdf file larger than 20MB it is showing out of memory issue like bellow.

Out of memory (allocated 439840768) (tried to allocate 116729376 bytes)

I need to store the pdf file in blob format in MySQL database without saving it in folder or some location.

I have changed all the settings in php.ini file to increase the memory limit, upload max size and execution time but no use.

I have checked all the solutions in stackoverflow and some other domains but not found useful answer.

Upvotes: 0

Views: 113

Answers (0)

Related Questions