Reputation: 4455
i created a web service for sending files and that saved in server. The file format is zip. The file size may vary in the user need.
This is my code for before sending data in to server.
$filename = $_SERVER['DOCUMENT_ROOT'].'/data.zip';
$data = file_get_contents($filename);
$new_data = base64_encode($data);
This new_data variable send to the server. This worked in all small files. But base64_encode return null when i use 5 mb file or larger file.
my problem is that base64_encode is not working in large string i genrated.
if any one know about this please help me.
Upvotes: 0
Views: 539
Reputation: 34113
The answer is simple: file_get_contents()
is returning false
which, when passed to base64_encode()
, results in an empty string.
Why is file_get_contents()
failing? It could be any number of reasons:
chmod()
may help, but it's likely something caused elsewhere.file_get_contents()
from loading 5 MB of text into memory.Upvotes: 1