• upload files with phpsdk

  • Do you want to create a native client or integrate with third party applications: webservices are the solution.
Do you want to create a native client or integrate with third party applications: webservices are the solution.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #40161  by rashedmohajer
 
Hello guys..
I want to upload documents through phpsdk using html form with input type file and another page with phpsdk
my openkm Version:openkm-6.3.0-communit
my Browser is firfox
and i used sdk Version:SDK for PHP 1.0.1
i Wishing you to help me because I am undergraduate and i use openkm in my project
 #40165  by sochoa
 
Example
Code: Select all
<?php

include '../src/openkm/OpenKM.php';
include './Config.php';

//ini_set('display_errors', true);
//error_reporting(E_ALL);

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;
use openkm\bean\Document;
use openkm\bean\Version;
use openkm\bean\Note;
use openkm\bean\LockInfo;
use openkm\util\ConverterHelper;
use openkm\exception\UnsupportMimeTypeException;
use openkm\exception\FileSizeExceededException;
use openkm\exception\VirusDetectedException;
use openkm\exception\PathNotFoundException;
use openkm\exception\AccessDeniedException;
use openkm\exception\RepositoryException;
use openkm\exception\DatabaseException;
use openkm\exception\UnknowException;
use Httpful\Exception\ConnectionErrorException;
use openkm\exception\ItemExistsException;
use openkm\exception\ExtensionException;
use openkm\exception\AutomationException;
use openkm\exception\UserQuotaExceededException;
use openkm\exception\IOException;
use openkm\exception\LockException;
use openkm\exception\VersionException;
use openkm\exception\ConversionException;
use openkm\exception\PrincipalAdapterException;

/**
 * TestDocument
 *
 * @author sochoa
 */
class TestDocument {

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(Config::HOST, Config::USER, Config::PASSWORD);
    }

    public function test() {
        try {
            /**
             * createDocumentSimple
             */
            $fileName = dirname(__FILE__) . '/files/test.html';
            $docPath = Config::TEST_DOC_HTML_PATH;
            $fileName = dirname(__FILE__) . '/files/test.odt';            
            $docPath = Config::TEST_DOC_WITH_SPACE;
            $document = $this->ws->createDocumentSimple($docPath, file_get_contents($fileName));
            echo '<p>' . $document->getPath() . '</p>'

        } catch (IOException $ioe) {
            echo '<p>' . $ioe->getMessage() . '</p>';
            echo '<p>' . $ioe->getTraceAsString() . '</p>';
        } catch (UnsupportMimeTypeException $usmte) {
            echo '<p>' . $usmte->getMessage() . '</p>';
            echo '<p>' . $usmte->getTraceAsString() . '</p>';
        } catch (FileSizeExceededException $fsee) {
            echo '<p>' . $fsee->getMessage() . '</p>';
            echo '<p>' . $fsee->getTraceAsString() . '</p>';
        } catch (UserQuotaExceededException $uqee) {
            echo '<p>' . $uqee->getMessage() . '</p>';
            echo '<p>' . $uqee->getTraceAsString() . '</p>';
        } catch (VirusDetectedException $vde) {
            echo '<p>' . $vde->getMessage() . '</p>';
            echo '<p>' . $vde->getTraceAsString() . '</p>';
        }  catch (AccessDeniedException $ade) {
            echo '<p>' . $ade->getMessage() . '</p>';
            echo '<p>' . $ade->getTraceAsString() . '</p>';
        } catch (PathNotFoundException $pnfe) {
            echo '<p>' . $pnfe->getMessage() . '</p>';
            echo '<p>' . $pnfe->getTraceAsString() . '</p>';
        } catch (RepositoryException $re) {
            echo '<p>' . $re->getMessage() . '</p>';
            echo '<p>' . $re->getTraceAsString() . '</p>';
        } catch (DatabaseException $de) {
            echo '<p>' . $de->getMessage() . '</p>';
            echo '<p>' . $de->getTraceAsString() . '</p>';
        } catch (ItemExistsException $iee) {
            echo '<p>' . $iee->getMessage() . '</p>';
            echo '<p>' . $iee->getTraceAsString() . '</p>';
        } catch (ExtensionException $ee) {
            echo '<p>' . $ee->getMessage() . '</p>';
            echo '<p>' . $ee->getTraceAsString() . '</p>';
        } catch (AutomationException $ae) {
            echo '<p>' . $ae->getMessage() . '</p>';
            echo '<p>' . $ae->getTraceAsString() . '</p>';
        } catch (UnknowException $ue) {
            echo '<p>' . $ue->getMessage() . '</p>';
            echo '<p>' . $ue->getTraceAsString() . '</p>';
        } catch (ConnectionErrorException $cee) {
            echo '<p>' . $cee->getMessage() . '</p>';
            echo '<p>' . $cee->getTraceAsString() . '</p>';
        } catch (Exception $e) {
            echo '<p>' . $e->getMessage() . '</p>';
            echo '<p>' . $e->getTraceAsString() . '</p>';
        }
    }

    public function getNamePath($path) {
        return substr($path, strrpos($path, '/') + 1);
    }

}

$openkm = new OpenKM();
$testDocument = new TestDocument();
$testDocument->test();
?>

Attachments
(278.4 KiB) Downloaded 303 times
 #40285  by rashedmohajer
 
hello
can i download file and their path like this:/okm:root/موسى/علي.jpg???
i try whit Encoade in UTF-8 but not work
 #40293  by jllort
 
Please do not merge different questions on same post, if you want to talk about download add other post, because merging different topics on same post usually may cause confusion to other users. Thanks
 #42309  by Harold
 
jllort wrote:Please do not merge different questions on same post, if you want to talk about download add other post, because merging different topics on same post usually may cause confusion to other users. Thanks
What if we don't have php 5 on our server?
 #42312  by jllort
 
You need installing php5, because the libraries used and application needs to have it installed, otherwise probably you will get errors while trying to execute it.

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.