Page 1 of 1

upload files with phpsdk

PostPosted:Sat Jul 25, 2015 8:40 am
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

Re: upload files with phpsdk

PostPosted:Sun Jul 26, 2015 1:45 am
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();
?>


Re: download files with phpsdk

PostPosted:Wed Aug 12, 2015 10:31 am
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

Re: upload files with phpsdk

PostPosted:Thu Aug 13, 2015 10:26 am
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

Re: upload files with phpsdk

PostPosted:Sat Sep 24, 2016 6:31 am
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?

Re: upload files with phpsdk

PostPosted:Sat Sep 24, 2016 4:47 pm
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.