Click here to Skip to main content
15,888,303 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

i am writing a class for the usage of Simogeo filemanager.

PHP
class FW_Class_Filemanager {

    private $uid = '';
    private $absPath = null;
    private $relPath = null;

    function __construct($path = null, $document_root = null)
    {
        $this->uid = uniqid();

        if ($document_root == null) {
            $document_root = $_SERVER['DOCUMENT_ROOT'];
        }

        if ($path == null) {
            $path = $document_root;
        }

        if (!mb_left($path, '/')) {
            $path = '/'.$path;
        }

        $this->absPath = $path;
        $this->relPath = $path;

        if (!mb_left($document_root, $this->absPath)){
            $this->absPath = $document_root.$this->absPath;
        }
        file_put_contents('/www/tmp/fm_'.$this->uid, $this->relPath.';'.$this->absPath);
        error_log(file_get_contents('/www/tmp/fm_'.$this->uid));
    }

    function build($width='98%', $height='400px')
    {
        $attributes = array(
            'src' => '/inc/lib/filemanager/index.php?uid='.$this->uid,
            'width' => $width,
            'height' => $height,
            'frameborder' => '0',
            'name' => 'filemanager_'.$this->uid,
        );
        $output = createSingleHtmlTag('iframe', $attributes, false);
        $output .= createSingleHtmlTag('iframe', null, true);
        return $output;
    }


then in my form i can:

PHP
$filemanager = new FW_Class_Filemanager('/data/files/' , null);
echo $filemanager->build();


when i call the class i give a path where i upload the files.
I store the files in a filestructure.

i know there is a way to set the root folder in php side:

PHP
$fm = new Filemanager();
);
$fm->setFileRoot('/data/files/');


but this is bade in the connectors/php/filemanager.php

im looking for a way to pass varriables to the filemanager.php so u can set the root dinamicaly.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900