AnsweredAssumed Answered

percorso upload file con php

Question asked by monocromo on Nov 9, 2012
Latest reply on Nov 9, 2012 by monocromo
Ciao a tutti, sto tentando di caricare alcuni file all'interno del repository di alfresco con l'SDK PHP trovato tra le applicazioni di Alfresco.
Sto riuscendo a farlo correttamente ma quello che non riesco a fare è inserire il file in una cartella della raccolta documenti del mio sito.

Il percorso che al momento sto utilizzando è:

$nodes = $session->query($spacesStore, "PATH:\"app:company_home/app:guest_home\"");

Io vorrei modificarlo ma non so come si possa recuperare quello di una cartella all'interno della raccolta documenti.

Lascio lo script php completo


* Copyright (C) 2005-2010 Alfresco Software Limited.
* This file is part of Alfresco
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <>.

    * Basic Tutorial Five - Exersice 1 (Solution)
    * Change the creation of the object to take its content from a local file.
    * See
    * Note: any changes to this file should be uploaded to the wiki
   // Include the required Alfresco PHP API objects 
   if (isset($_SERVER["ALF_AVAILABLE"]) == false)
       require_once "Alfresco/Service/Repository.php";
      require_once "Alfresco/Service/Session.php";
      require_once "Alfresco/Service/SpacesStore.php";
      require_once "Alfresco/Service/ContentData.php";

   // Specify the connection details
   $repositoryUrl = "";
   $userName = "admin";
   $password = "fenice";
   // 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);
   // 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/app:guest_home\"");
   $guestHome = $nodes[0];
   // Update the property if the form has been posted with the correct details
   if (isset($_REQUEST["create"]) == true)
      // Get the name of the new node
      $name = $_REQUEST["name"];
      // Create the new content node
      //  - parameter one is the type of node we want to create
      //  - parameter two is the association type, this should be contains for normal files and folders
      //  - parameter three is the association name, this should be the name of the file or folder under normal
      //    circumstances
      $contentNode = $guestHome->createChild("cm_content", "cm_contains", "cm_".$name);
      // Add the titles aspect to the new node so that the title and description properties can be set
      // Set the name, title and description property values
      $contentNode->cm_name = $name;
      $contentNode->cm_title = $_REQUEST["title"];
      $contentNode->cm_description = $_REQUEST["description"];
      // 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['file']['type'], "UTF-8");
      // Set the content to be the content file uploaded from the client
      // Save the new node


   <title>Basic Tutorial Five - Create Content Node</title>

    <big>Basic Tutorial Five - Create Content Node</big><br><br>
    <form action="BasicTutorial5-Exercise1.php" method="post" enctype="multipart/form-data">
       <input type=hidden name=create value="true">
       <table border=0 cellpadding=2 cellspacing=3>
             <td><input name="name" type=edit size=50></td>
             <td><input name="title" type=edit size=50></td>
             <td><input name="description" type=edit size=50></td>
             <td><input name="file" size="50" type="file"></td>
             <td align=right><input type=submit value="Create Node"></td>
   if (isset($_REQUEST["create"]) == true)
     // Calculate the url to the properties of the new node
     $uiUrl = "http://'.$repository->host.":".$repository->port."/alfresco/n/showDocDetails/workspace/SpacesStore/".$contentNode->id;
     <p style="color:red">The new content node has been created.  Go to <a target="new" href="<?php echo $uiUrl ?>">here</a> to view its properties.</p>