upload files with phpsdk

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.
Post Reply
rashedmohajer
Junior Boarder
Junior Boarder
Posts: 22
Joined: Sat Jul 25, 2015 8:03 am
Location: sudan

upload files with phpsdk

Post by rashedmohajer » Sat Jul 25, 2015 8:40 am

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

sochoa
Junior Boarder
Junior Boarder
Posts: 29
Joined: Thu May 02, 2013 3:26 am

Re: upload files with phpsdk

Post by sochoa » Sun Jul 26, 2015 1:45 am

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
sdk4php-1.0.4.zip
(278.4 KiB) Downloaded 33 times

rashedmohajer
Junior Boarder
Junior Boarder
Posts: 22
Joined: Sat Jul 25, 2015 8:03 am
Location: sudan

Re: download files with phpsdk

Post by rashedmohajer » Wed Aug 12, 2015 10:31 am

hello
can i download file and their path like this:/okm:root/موسى/علي.jpg???
i try whit Encoade in UTF-8 but not work

jllort
Moderator
Moderator
Posts: 9374
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: upload files with phpsdk

Post by jllort » Thu Aug 13, 2015 10:26 am

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

Harold
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: Fri Sep 23, 2016 7:12 am

Re: upload files with phpsdk

Post by Harold » Sat Sep 24, 2016 6:31 am

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?

jllort
Moderator
Moderator
Posts: 9374
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: upload files with phpsdk

Post by jllort » Sat Sep 24, 2016 4:47 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest