Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to change the working directory #2

Open
danielcorrea opened this issue Mar 11, 2014 · 14 comments
Open

how to change the working directory #2

danielcorrea opened this issue Mar 11, 2014 · 14 comments

Comments

@danielcorrea
Copy link

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?

@jcampbell1
Copy link
Owner

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 notifications@github.comwrote:

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//issues/2
.

@andreibordeianu
Copy link

I'm also interested in this issue.

@jaredjones
Copy link

I'm interested as well, it would also be cool to view multiple working directories at once.

@ghost ghost mentioned this issue Nov 19, 2015
@rezatbaher
Copy link

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();

@EwoutV6
Copy link

EwoutV6 commented Mar 2, 2017

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.

@mungle
Copy link

mungle commented Mar 8, 2017

Hello! News about this feature?
Thanks

@harikrishnanr994
Copy link

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),
];
}
}

@bigicoin
Copy link

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!

@johnwmail
Copy link

Please support this feature +1

This was referenced Oct 24, 2019
@jcampbell1
Copy link
Owner

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:

  1. work as expected in most cases
  2. 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.

@murulimadhav
Copy link

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?

@flattery103
Copy link

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.

@abdes-zakari
Copy link

2412393

@johnwmail
Copy link

I had changed the "$tmp_dir", point it to new root, it work for me over a year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests