AnsweredAssumed Answered

Can't preview uploaded document using CMIS (in PHP)

Question asked by mperez on Aug 8, 2017

I'm using GitHub - donbalon4/API_Alfresco  (API for Apache Chemistry) to upload files through CMIS to my Alfresco repository from a PHP site.

 

Everything is working as expected, but Alfresco seems not to be able to preview documents when I left-click on them. If I click "View in browser" then I can view it perfectly.

 

Here's my code so far:

 

<?php
    require 'APIAlfresco/APIAlfresco.php';
    include 'connectAlfresco.php';

 

    $parent_name = $_POST['parent'];
    $uploaded_file = basename($_FILES['att_file']['name']); //Uploaded
    $base_folder = "/path/to/site/folder/"

 

    if (move_uploaded_file($_FILES['att_file']['tmp_name'], $uploaded_file)) {

 

            $conexion->setFolderByPath($base_folder); //Set base folder where files will be uploaded

 

        /*Check if dir already exists and create it if it doesn't */
            if($conexion->existsFolder($parent_name)) echo "Parent".$parent_name." already exists";
            else $conexion->createFolder($parent_name);

 

      /*Move uploaded file into folder */
            $conexion->setFolderByPath($base_folder."/".$parent_name);
            $conexion->uploadFile($uploaded_file);

    }

    echo 'File infor:';
    print_r($_FILES);

    ?>

 

I guess that uploaded file is losing some kind of metadata so then Alfresco can not preview it. Any clue what's happening?

 

Thanks in advance.

Outcomes