simple-file-manager
simple-file-manager copied to clipboard
how to change the working directory
how to change the working directory
I have the following structure: / / admin - here's the simple-file-manager / images - here are the files it should manage.
Where do I change the working path of the script?
I didn't consider this use case. I'll look into making this possible.
On Tue, Mar 11, 2014 at 12:33 PM, Daniel Correa [email protected]:
how to change the working directory
I have the following structure: / / admin - here's the simple-file-manager / images - here are the files it should manage.
Where do I change the working path of the script?
— Reply to this email directly or view it on GitHubhttps://github.com/jcampbell1/simple-file-manager/issues/2 .
I'm also interested in this issue.
I'm interested as well, it would also be cool to view multiple working directories at once.
nice job ! it would be nice to be able to call this script as an object . for example include '/path/to/index.php' $FileManager = new FileManager('path to directory of uploads'); print $FileManager->create();
chdir() seems to do the trick: http://php.net/manual/en/function.chdir.php
PHP File Manager in /www and Files (to manage) in /www/images
chdir('images'); or chdir('/www/images') is al it takes.
Hello! News about this feature? Thanks
you can change the root folder in the program itself. You have to change it in 2 parts .
1: upload part.
foreach($disallowed_extensions as $ext) if(preg_match(sprintf('/.%s$/',preg_quote($ext)), $_FILES['file_data']['name'])) err(403,"Files of this type are not allowed."); //echo $_FILES['file_data']['name']; var_dump(move_uploaded_file($_FILES['file_data']['tmp_name'], "NEWROOT/".$file.'/'.$_FILES['file_data']['name'])); exit; }
2 : view part . if($_GET['do'] == 'list') { if (is_dir($file)) { $directory = $file**."/NEWROOT"**; // Change NEWROOT to the file you require . $result = []; $files = array_diff(scandir($directory), ['.','..']); foreach($files as $entry) if($entry !== basename(FILE)) { $i = $directory . '/' . $entry; $stat = stat($i); $result[] = [ 'mtime' => $stat['mtime'], 'size' => $stat['size'], 'name' => basename($i), 'path' => preg_replace('@^./@', '', $i), 'is_dir' => is_dir($i), 'is_deleteable' => $allow_delete && ((!is_dir($i) && is_writable($directory)) || (is_dir($i) && is_writable($directory) && is_recursively_deleteable($i))), 'is_readable' => is_readable($i), 'is_writable' => is_writable($i), 'is_executable' => is_executable($i), ]; } }
I was able to use the chdir() trick mentioned by EwoutV6 and got this working, by putting it right before the meat of the directory logic (if($_GET['do'] == 'list') {...). I also replaced $tmp_dir, but it looks like it didn't matter.
It would be cool if the Simple File Manager code could take in a source path as a config parameter at the beginning of the code, and let us simply set it cleanly that way. :) Otherwise, very cool and useful script!
Please support this feature +1
This is a bit tricky because it assumes the files are addressable by the web server. There isn't a easy option to add that will:
- work as expected in most cases
- Not introduce a security issue
For instance, if people want to serve the files in /home/person/photos/ then the photos won't be served by the web server if I add that option.
Creating a symlink on the server may solve many cases.
nice job ! it would be nice to be able to call this script as an object . for example include '/path/to/index.php' $FileManager = new FileManager('path to directory of uploads'); print $FileManager->create();
how to do this?
Look in the commits section. Someone has committed code for this setting, but it hasn't been merged yet. Just use the file from that section and it works.
https://github.com/jcampbell1/simple-file-manager/pull/113/commits/241239382182c31d2296029e29d34d1806f87fce
I had changed the "$tmp_dir", point it to new root, it work for me over a year.