PHP code example of zdenekgebauer / dosiero

1. Go to this page and download the library: Download zdenekgebauer/dosiero library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zdenekgebauer / dosiero example snippets



declare(strict_types=1);

/**
 * entry point of server part of connector
 *
 * always expects:
 * $_GET['action'] - requested action. Some actions h properties:
 * msg - error message
 * folders - tree of folders. Returned if action change folders
 * files - list of folders and files in given path. Returned if action change files in current path
 *
 * action "folders"
 * - returns property "folders" with all directories as array of objects. Each object represents one folder
 *   and contains array "subfolders" with nested folders and files
 *
 * action "files"
 * - returns property "files" with folders and files in current path
 *
 * action "mkdir" create new folder
 * -  $_POST['target_storage'] with name of target storage
 *
 * action "move" moves file in current path to another folder
 * - ;
$localStorage->setOption(LocalStorage::OPTION_BASE_URL, 'https://yourserver/data');
$localStorage->setOption(LocalStorage::OPTION_MODE_DIRECTORY, 0775);
$localStorage->setOption(LocalStorage::OPTION_MODE_FILE, 0664);

try {
    $connector = new Connector($config);
    $connector->addStorage($localStorage);
    $response = $connector->handleRequest();
} catch (AccessForbiddenException $exception) {
    $response = new Response(403, $exception->getMessage());
} catch (StorageException $exception) {
    $response = new Response(400, $exception->getMessage());
} catch (InvalidRequestException $exception) {
    $response = new Response(400, $exception->getMessage());
} catch (Exception $exception) {
    $response = new Response(500, 'unexpected problem: ' . $exception->getMessage());
}

// if is called from different domain, set CORS
// $response->allowAccessFromDomain('*');
// or $response->allowAccessFromDomain('https://otherdomain/');
$response->sendOutput();