Karl I really have to say, I think you are confused.
That's what I'd say about you, unfortunately. Despite my best efforts it seems I haven't been able to convey the actual issue that I am encountering and we are talking about two different things at every step.
Case in point:
Karl Files Gallery root
might not be inside Config::$__dir__
I'm not talking about where root
is! I haven't ever been talking about that, and it isn't the source of any issues. If you look at my first post about this, you will see where the problem comes from:
sev I tried to set up custom.js
like your guide says but found it wasn't being linked. I looked into it and noticed Path::urlpath
bails early if the path is not within document_root
.
The problem there is that the file custom.js
—which normally lives in /_files/js
, not talking about root
or any user files here—doesn't have a link inserted for it, because it is technically outside of DOCUMENT_ROOT
.
...But, if I disable the check that sees if it is outside DOCUMENT_ROOT
, the link is still made (since it is relative to __DIR__
, and it can build links relative to __DIR__
) and _files/js/custom.js
is now inserted into the page. And my proxy sends the file, because that's what I configured it to do. Even though, yes, it is outside of PHP's DOCUMENT_ROOT
. It still builds a link and the file is still served to the client.
From there I have just been trying to explain the issue, and the details around it... Our misunderstanding eachother started from the very first post:
Karl I'm not sure how you are setup, but a CSS file needs to be within document root to be able to load from browser.
This simply isn't true, and I would like to think I showed you how such a thing is possible, and explained how and why it's possible, and why you might want or need to do such a thing.
Karl PHP and Files Gallery will use $_SERVER['DOCUMENT_ROOT']
to determine what files are readable from the www, as this is kinda the point of having a document root.
But the Files Gallery root
I want to serve is outside of DOCUMENT_ROOT
. Unfortunately, there is simply no way I can have it be inside of DOCUMENT_ROOT
, unless I point DOCUMENT_ROOT
at where I am pointing root
, which is what I have done. But now checks fail related to $storagepath
, caching, and etc., because now they are outside of DOCUMENT_ROOT
. I am unable to have both root
and $storagepath
be inside of DOCUMENT_ROOT
, I can only have one or the other. It just doesn't work in my environment. Now you may certainly argue that this situation is outside of the use-case and support of Files Browser, and that's fine if so. But otherwise, this is clearly a limitation of the software.
Karl If you have document root /var/www/website/public
and then you have a file /some/other/path
(outside document root), then what is the "url" for that file?
It can be whatever you want it to be. There is no limitation or restriction. DOCUMENT_ROOT
is merely a guideline and a convention. It's not even part of the CGI spec that the [F]CGI SAPI modules were based on, it's an Apache-derived thing. In this case, I merely suggested that __DIR__
could be used as a common root for building URLs around $storagepath
if it is outside DOCUMENT_ROOT
. If $storagepath
isn't inside __DIR__
, then that does change things, and the logic would need to account for that as well.
Another approach would simply be to have a config setting that tells Files Gallery "my $storagepath
is available on my web server at the URI /_files
" and then Files Gallery can build its URLs out of that. If the URL can be automatically created without this configuration, great... but if it can't, that value can be used as a fallback—or it can alternatively override whatever Files Gallery would otherwise generate based on the filesystem and DOCUMENT_ROOT
.
If you still don't understand what the issue is, let's just move on. I have deployed changes to make it work for me, and I have no problem maintaining them myself. At the very least, I must thank you for providing Files Gallery in such an open and modifiable manner 🙂
Back to the JavaScript:
sev What is _h, and what code have you added, and/or perhaps a screenshot?

Error: Uncaught ReferenceError: _h is not defined
The code
sev
_c.config = {
// custom context menu (dropdown) options
contextmenu: {
rotate: {
text: 'rotate',
// icon name, or include custom icon <path d="..."> value from https://pictogrammers.com/library/mdi/
icon: 'rotate_right',
condition: (item) => item.browser_image,
// href: (item) => { return item.url_path; },
action: (item) => _h.popup(null, null, null, item.url_path),
// class: 'mybutton'
},
},
}
This is copied 1:1 from the Advanced Javascript Config documentation. And I looked inside the Files Browser bundle, and I can see where var _h
is defined. I can only imagine it isn't in scope, so the action
is unable to call it.