ztimer Posted January 7, 2012 Share Posted January 7, 2012 Hi. What i would like is to post a user_id value to connector.php to make the home and root directory based on the value i need at the moment. i have a page that shows user details and i have a value $user_id = $_GET['selected_worker']; <!-- elFinder initialization (REQUIRED) --> <script type="text/javascript" charset="utf-8"> $().ready(function() { var elf = $('#elfinder').elfinder({ lang: 'ru', // language (OPTIONAL) url : 'php/connector.php', // connector URL (REQUIRED) directory : 'files' }).elfinder('instance'); }); </script> the actual connector.php <?php error_reporting(0); // Set E_ALL for debuging include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderConnector.class.php'; include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinder.class.php'; include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeDriver.class.php'; include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeLocalFileSystem.class.php'; // Required for MySQL storage connector //include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeMySQL.class.php'; /** * Simple function to demonstrate how to control file access using "accessControl" callback. * This method will disable accessing files/folders starting from '.' (dot) * * @param string $attr attribute name (read|write|locked|hidden) * @param string $path file path relative to volume root directory started with directory separator * @return bool **/ function access($attr, $path, $data, $volume) { return strpos(basename($path), '.') === 0 // if file/folder begins with '.' (dot) ? !($attr == 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true : ($attr == 'read' || $attr == 'write'); // else set read+write to true, locked+hidden to false } // This works when manually adding $user_id= "323"; // Not working when $user_id= $_GET['selected_worker']; $opts = array( // 'debug' => true, 'roots' => array( array( 'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED) 'path' => '../'.$user_id.'/', // path to files (REQUIRED) 'URL' => dirname($_SERVER['PHP_SELF']) . '/../'.$user_id.'/', // URL to files (REQUIRED) 'accessControl' => 'access' // disable and hide dot starting files (OPTIONAL) ) ) ); // run elFinder $connector = new elFinderConnector(new elFinder($opts)); $connector->run(); How can i post a value to the connector.php Any ideas ? Please help. Quote Link to comment https://forums.phpfreaks.com/topic/254548-elfinder-want-to-post-a-value-to-connectorphp/ Share on other sites More sharing options...
Vel Posted January 7, 2012 Share Posted January 7, 2012 The most obvious answer to me is to send them as get variables. <!-- elFinder initialization (REQUIRED) --> <script type="text/javascript" charset="utf-8"> $().ready(function() { var elf = $('#elfinder').elfinder({ lang: 'ru', // language (OPTIONAL) url : 'php/connector.php?id=<?php echo $user_id; ?>', // connector URL (REQUIRED) directory : 'files' }).elfinder('instance'); }); </script> Then in connector.php just use $_get['id']. Quote Link to comment https://forums.phpfreaks.com/topic/254548-elfinder-want-to-post-a-value-to-connectorphp/#findComment-1305294 Share on other sites More sharing options...
ztimer Posted January 7, 2012 Author Share Posted January 7, 2012 Hi. Thank you for your answer. This way of using the url to post was the first thing i tried but no luck. It just was not able to get the info. So i managed to make another post using the actual script itself. Then i got it to work. And for others out there i will post my findings. Hope it helps somebody. <?php $customdirectory = "../files/22"; ?> <!-- elFinder initialization (REQUIRED) --> <script type="text/javascript"> $().ready(function() { var elf = $('#elfinder').elfinder({ url : 'php/connector.php', customData : { startPath : "<?php echo $customdirectory ?>" }, rememberLastDir : false }).elfinder('instance'); }); </script> The connector.php <?php error_reporting(0); // Set E_ALL for debuging include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderConnector.class.php'; include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinder.class.php'; include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeDriver.class.php'; include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeLocalFileSystem.class.php'; function access($attr, $path, $data, $volume) { return strpos(basename($path), '.') === 0 // if file/folder begins with '.' (dot) ? !($attr == 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true : ($attr == 'read' || $attr == 'write'); // else set read+write to true, locked+hidden to false } $filePath = '../files'; $startPath = $filePath; if(isset($_GET['startPath']) && !empty($_GET['startPath'])) { $startPath .= '/'.$_GET['startPath']; } $opts = array( // 'debug' => true, 'roots' => array( array( 'driver' => 'LocalFileSystem', 'path' => $startPath, 'startPath' => $startPath, 'accessControl' => 'access' ) ) ); $connector = new elFinderConnector(new elFinder($opts)); $connector->run(); ?> The most obvious answer to me is to send them as get variables. <!-- elFinder initialization (REQUIRED) --> <script type="text/javascript" charset="utf-8"> $().ready(function() { var elf = $('#elfinder').elfinder({ lang: 'ru', // language (OPTIONAL) url : 'php/connector.php?id=<?php echo $user_id; ?>', // connector URL (REQUIRED) directory : 'files' }).elfinder('instance'); }); </script> Then in connector.php just use $_get['id']. Quote Link to comment https://forums.phpfreaks.com/topic/254548-elfinder-want-to-post-a-value-to-connectorphp/#findComment-1305299 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.