如何使用PHP在alfresco上传图像文件

时间:2021-12-05 21:22:52

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

我想使用PHP使用cmis api将图像文件上传到alfresco ..我可以使用以下代码在alfresco中创建简单的文本文档

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

I tried following code to upload image

我尝试使用代码上传图片

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

But can't create image file into alfresco

但无法将图像文件创建到露天

Can anyone help me to solve this issue ??

任何人都可以帮我解决这个问题吗?

1 个解决方案

#1


1  

I got the solution of this problem

我得到了这个问题的解决方案

Just store base64 content into image.. Use below code

只需将base64内容存储到图像中..使用下面的代码

$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


1  

I got the solution of this problem

我得到了这个问题的解决方案

Just store base64 content into image.. Use below code

只需将base64内容存储到图像中..使用下面的代码

$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");