El siguiente es el código PHP para cargar archivos usando Alfresco Web Service. Pongo algunos comentarios dentro del código. Si hay algo que te confunda, deja tu comentario y espero poder ayudarte.
if (isset($_SERVER["ALF_AVAILABLE"]) == false) { require_once "./alfresco_sdk/remote/Alfresco/Service/Repository.php"; require_once "./alfresco_sdk/remote/Alfresco/Service/Session.php"; require_once "./alfresco_sdk/remote/Alfresco/Service/SpacesStore.php"; require_once "./alfresco_sdk/remote/Alfresco/Service/ContentData.php"; } $repositoryUrl = "http://localhost:8080/alfresco/api"; $userName = "admin"; $password = "admin"; // Authenticate the user and create a session $repository = new Repository($repositoryUrl); $ticket = $repository->authenticate($userName, $password); $session = $repository->createSession($ticket); // Create a reference to the 'SpacesStore' $spacesStore = new SpacesStore($session); $dir_name = "s".$irbID; // Use a serach to get the guest home space we will use to place the new content in $nodes = $session->query($spacesStore, "PATH:"app:company_home/cm:testing/cm:$dir_name""); if(!empty($nodes)){ echo "good, no need to do anything."; }else{ $nodes = $session->query($spacesStore, "PATH:"app:company_home/cm:testing""); $contentNode = $nodes[0]; $newSpace = $contentNode->createChild('cm_folder', 'cm_contains', 'cm_'.$dir_name);//here has to be cm_ as it is here. $newSpace->cm_name = $dir_name; $newSpace->cm_title = "This is a title"; $newSpace->cm_description = 'Description of Space'; $session->save(); unset($session); $session = $repository->createSession($ticket); $nodes = $session->query($spacesStore, "PATH:"app:company_home/cm:testing/cm:$dir_name""); } $guestHome = $nodes[0]; // Get the name of the new node $name = $_POST['txt_docs_title']; $contentNode = $guestHome->createChild("cm_content", "cm_contains", "cm_".$name);//!!the folder's name has to begin with 'cm_' otherwise, using web service can not find it later. $contentNode->addAspect("cm_titled"); // Set the name, title and description property values $contentNode->cm_name = $name; $contentNode->cm_title = $_POST['num_ct_ID']; $contentNode->cm_description = "testing description --program creek"; // Set the content onto the standard content property for nodes of type cm:content. // We are going to assume the mimetype and encoding for ease $contentData = $contentNode->updateContent("cm_content", $_FILES['document']['type'], "UTF-8"); // Set the content to be the content file uploaded from the client $contentData->writeContentFromFile($_FILES["document"]["tmp_name"]); // Save the new node $session->save(); |