How to upload image file to alfresco using php

I want to upload an image file to alfresco using cmis api using PHP. I can create a simple text document in alfresco using the following code

$obs = $client->createDocument($myfolder->id, $repo_new_file,$prop, "testssss", "text/plain");

I tried the following image upload code

$obs = $client->createDocument($myfolder->id, $repo_new_file,$prop, null, "image/jpeg");

But unable to create image file all over the world

Can someone help me solve this problem?

+4
source share
1 answer

I got a solution to this problem

Just load the contents of base64 into the image. Use below code

$filename="A.jpg";
$handle = fopen($filename, "r");
if(!$handle)return FALSE;
$contents = fread($handle, filesize($filename));
if(!$mimetype)$type=mime_content_type($filename);
else $type=$mimetype;
fclose($handle);
$base64_content=base64_encode($contents);
$obs = $client->createDocument($myfolder->id, $repo_new_file,$prop, base64_decode($base64_content), "image/jpg");
+1
source

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


All Articles