SOS PHP help: Image Base64 Encoding

iosoft

PC enthusiast since MS DOS 5
Skilled
Hi

I need a help in Base64 Encoding of Image file.

I need to set a communication between two servers where the packet have to be in XML format and files should be in Base64 mode.

Procedure says -
Requires:

* sessionkey (string, 32)
* title (string, 32)
* data (string)

The image data must be the base64 encoded title.

I am doing this -
PHP:
$tempfile='/home/ayan/public_html/test.jpg';
$handle = fopen($tempfile,'rb');
$file_content = fread($handle,filesize($tempfile));
fclose($handle);
$encoded = base64_encode($file_content);

$process['sessionkey']='8b285f12771286e5cf0c139358e7fbf9'; // arbitary
$process['title']='test.jpg';

// Trying both
// $process['data']=$encoded;
$process['data']='data:image/jpeg;base64,'.$encoded;

$client->query('Server.saveData', $process);
Output is :huh: -
Array ( [faultCode] => 5 [faultString] => decoded data does not match title )
I think, the problem is here -
The image data must be the base64 encoded title.

What does it mean ? What title ?

Please help, stacked for a month :(
 
I'm guessing the image name should be encoded too...and this is the only title in the code.

PHP:
$process['title']='test.jpg';

give it a try.

PHP:
$process['title']== base64_encode('test.jpg');
 
Back
Top