In a server sided script I am using the following PHP code to encode an image:
$handle = fopen($imageSrc,'r');
$file_content = fread($handle,filesize($imageSrc));
fclose($handle);
$encoded = base64_encode($file_content);
echo $encoded;
When I read the file through a webservice it has the length 9309 bytes which is an invalid length for base64 encoded data. Examining the data, I found out that the value last byte is 10 (LF). Right now I am cropping the last byte away in my webservices before decoding the data. Is there a clean way to avoid the LF character to be sent?