[GH-ISSUE #490] Opening and previewing files not working. #361

Closed
opened 2026-03-02 15:58:07 +03:00 by kerem · 10 comments
Owner

Originally created by @pgram1 on GitHub (Jan 28, 2021).
Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/490

So far I have tried

  • default root path
// Root path for file manager
// use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder'
$root_path = $_SERVER['DOCUMENT_ROOT'];

// Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder'
// Will not working if $root_path will be outside of server document root
$root_url = '';

// Server hostname. Can set manually if wrong
$http_host = '[some ip]';
  • a simple change of the root path
// Root path for file manager
// use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder'
$root_path = $_SERVER['DOCUMENT_ROOT'].'/files';

// Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder'
// Will not working if $root_path will be outside of server document root
$root_url = '';

// Server hostname. Can set manually if wrong
$http_host = '[some ip]';
  • a simple change of the root path plus a change of the root url
// Root path for file manager
// use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder'
$root_path = $_SERVER['DOCUMENT_ROOT'].'/files';

// Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder'
// Will not working if $root_path will be outside of server document root
$root_url = 'files';

// Server hostname. Can set manually if wrong
$http_host = '[some ip]';

My environment is the default PHP server, by running sudo php -S 0.0.0.0:8080 tinyfilemanager.php (therefore I am running as root.). My directories are also set to 777 (This is a local installation behind a firewall, I don't care about security).

Am I doing something wrong?

I browsed similar answered issues but they were related to user-specific folders. My issue is with any file opening or previewing a file. Creation, Modification, Deletion, Uploading and Downloading all work fine. Curiously quick preview works for simpletext files only.

Originally created by @pgram1 on GitHub (Jan 28, 2021). Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/490 # So far I have tried - default root path ``` // Root path for file manager // use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder' $root_path = $_SERVER['DOCUMENT_ROOT']; // Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder' // Will not working if $root_path will be outside of server document root $root_url = ''; // Server hostname. Can set manually if wrong $http_host = '[some ip]'; ``` - a simple change of the root path ``` // Root path for file manager // use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder' $root_path = $_SERVER['DOCUMENT_ROOT'].'/files'; // Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder' // Will not working if $root_path will be outside of server document root $root_url = ''; // Server hostname. Can set manually if wrong $http_host = '[some ip]'; ``` - a simple change of the root path plus a change of the root url ``` // Root path for file manager // use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder' $root_path = $_SERVER['DOCUMENT_ROOT'].'/files'; // Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder' // Will not working if $root_path will be outside of server document root $root_url = 'files'; // Server hostname. Can set manually if wrong $http_host = '[some ip]'; ``` My environment is the default PHP server, by running `sudo php -S 0.0.0.0:8080 tinyfilemanager.php` (therefore I am running as root.). My directories are also set to 777 (This is a local installation behind a firewall, I don't care about security). Am I doing something wrong? I browsed similar answered issues but they were related to user-specific folders. My issue is with any file opening or previewing a file. Creation, Modification, Deletion, Uploading and Downloading all work fine. Curiously quick preview works for simpletext files only.
kerem 2026-03-02 15:58:07 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@EV-soft commented on GitHub (Jan 29, 2021):

"This is a local installation behind a firewall"
Does that mean the script does not have internet access ?
Preview and editing with online_viewer depend on web access:

if ($is_onlineViewer) {
                if($online_viewer == 'google') {
                    echo '<iframe src="https://docs.google.com/viewer?embedded=true&hl=en&url=' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height:460px"></iframe>';
                } else if($online_viewer == 'microsoft') {
                    echo '<iframe src="https://view.officeapps.live.com/op/embed.aspx?src=' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height:460px"></iframe>';
                }
            }

See #288

<!-- gh-comment-id:769765718 --> @EV-soft commented on GitHub (Jan 29, 2021): "This is a local installation behind a firewall" Does that mean the script does not have internet access ? Preview and editing with online_viewer depend on web access: ``` if ($is_onlineViewer) { if($online_viewer == 'google') { echo '<iframe src="https://docs.google.com/viewer?embedded=true&hl=en&url=' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height:460px"></iframe>'; } else if($online_viewer == 'microsoft') { echo '<iframe src="https://view.officeapps.live.com/op/embed.aspx?src=' . fm_enc($file_url) . '" frameborder="no" style="width:100%;min-height:460px"></iframe>'; } } ``` See #288
Author
Owner

@pgram1 commented on GitHub (Jan 29, 2021):

@EV-soft

The script has internet access but is not to be accessed by users on the internet. People outside my LAN need not access it.

It is used internally within the LAN, thus I am not concerned about the security of the installation more than its functionality (which hints I am willing to try insecure workarounds if advised so).

Also, the problem is that I cannot preview/open HTML pages or images. And generally any file for that matter. In my initial issue I specify:

My issue is with any file opening or previewing a file. Creation, Modification, Deletion, Uploading and Downloading all work fine.

This is a step by step procedure of me trying to open an HTML page:

Step 1: Finding the file
image
Step 2: Clicking inside and then "Open"
image
Step 3: Get thrown back to index.
image

This is a step by step procedure of me trying to preview or open an image:

Step 1: Trying to preview thumbnail
image
Step 2: Trying to preview image
image
(image not visible in preview window)

Step 3: Trying to open the image. Take a note of the link presented below when I hover over the button vs the full path of the image depicted at the top. The full path is correct yet the link to open sends me back to index.
image

And then again it throws me back to index just like the previous example.

The files are all with 777 permissions and the php server even runs as root.

I didn't try to access documents but I am aware of what you are showing me there, it is indeed an embedded google docs viewer that is needed to open documents. I was not trying to use that feature though.

<!-- gh-comment-id:770024883 --> @pgram1 commented on GitHub (Jan 29, 2021): @EV-soft The script has internet access but is not to be accessed by users on the internet. People outside my LAN need not access it. It is used internally within the LAN, thus I am not concerned about the security of the installation more than its functionality (which hints I am willing to try insecure workarounds if advised so). Also, the problem is that I cannot preview/open HTML pages or images. And generally any file for that matter. In my initial issue I specify: > My issue is with any file opening or previewing a file. **Creation, Modification, Deletion, Uploading and Downloading all work fine**. This is a step by step procedure of me trying to open an HTML page: Step 1: Finding the file ![image](https://user-images.githubusercontent.com/30127221/106320947-3cc5e100-627c-11eb-8158-93224650030c.png) Step 2: Clicking inside and then "Open" ![image](https://user-images.githubusercontent.com/30127221/106321004-56ffbf00-627c-11eb-812f-dfe8957cc4e0.png) Step 3: Get thrown back to index. ![image](https://user-images.githubusercontent.com/30127221/106321119-87dff400-627c-11eb-906f-86a46ff8e68e.png) This is a step by step procedure of me trying to preview or open an image: Step 1: Trying to preview thumbnail ![image](https://user-images.githubusercontent.com/30127221/106321469-ffae1e80-627c-11eb-824e-6ac55311d415.png) Step 2: Trying to preview image ![image](https://user-images.githubusercontent.com/30127221/106321534-18b6cf80-627d-11eb-8b47-196e8a3eaa28.png) (image not visible in preview window) Step 3: Trying to open the image. Take a note of the link presented below when I hover over the button vs the full path of the image depicted at the top. The full path is correct yet the link to open sends me back to index. ![image](https://user-images.githubusercontent.com/30127221/106321740-66cbd300-627d-11eb-8634-7c63154fa273.png) And then again it throws me back to index just like the previous example. The files are all with 777 permissions and the php server even runs as root. I didn't try to access documents but I am aware of what you are showing me there, it is indeed an embedded google docs viewer that is needed to open documents. I was not trying to use that feature though.
Author
Owner

@prasathmani commented on GitHub (Feb 4, 2021):

did you change default $root_path configuration. usually preview will get error when $root_path and $root_url configured wrongly.

<!-- gh-comment-id:773342923 --> @prasathmani commented on GitHub (Feb 4, 2021): did you change default `$root_path` configuration. usually preview will get error when `$root_path` and `$root_url` configured wrongly.
Author
Owner

@pgram1 commented on GitHub (Feb 4, 2021):

did you change default $root_path configuration. usually preview will get error when $root_path and $root_url configured wrongly.

It is definitely one of the two settings that is wrong. Point is I could not figure it out myself and thus I tried to explain the steps I went through in detail above. I think I have covered the combinations of $root_path and $root_url I should have had, that's why I posted it as an issue..

<!-- gh-comment-id:773404431 --> @pgram1 commented on GitHub (Feb 4, 2021): > > > did you change default `$root_path` configuration. usually preview will get error when `$root_path` and `$root_url` configured wrongly. It is definitely one of the two settings that is wrong. Point is I could not figure it out myself and thus I tried to explain the steps I went through in detail above. I think I have covered the combinations of `$root_path` and `$root_url` I should have had, that's why I posted it as an issue..
Author
Owner

@prasathmani commented on GitHub (Feb 5, 2021):

kindly share the $root_path and $root_url config to help you on this.

<!-- gh-comment-id:773780782 --> @prasathmani commented on GitHub (Feb 5, 2021): kindly share the `$root_path` and `$root_url` config to help you on this.
Author
Owner

@pgram1 commented on GitHub (Feb 8, 2021):

kindly share the $root_path and $root_url config to help you on this.

The full path of what I want to make the home directory is /home/alarm/.fileserver/files/

The path where the tinyfilemanager script exists is /home/alarm/.fileserver/tinyfilemanager.php

I tried all the configs described at my first post

So far I have tried

  • default root path
// Root path for file manager
// use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder'
$root_path = $_SERVER['DOCUMENT_ROOT'];

// Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder'
// Will not working if $root_path will be outside of server document root
$root_url = '';

// Server hostname. Can set manually if wrong
$http_host = '[some ip]';
  • a simple change of the root path
// Root path for file manager
// use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder'
$root_path = $_SERVER['DOCUMENT_ROOT'].'/files';

// Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder'
// Will not working if $root_path will be outside of server document root
$root_url = '';

// Server hostname. Can set manually if wrong
$http_host = '[some ip]';
  • a simple change of the root path plus a change of the root url
// Root path for file manager
// use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder'
$root_path = $_SERVER['DOCUMENT_ROOT'].'/files';

// Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder'
// Will not working if $root_path will be outside of server document root
$root_url = 'files';

// Server hostname. Can set manually if wrong
$http_host = '[some ip]';

My environment is the default PHP server, by running sudo php -S 0.0.0.0:8080 tinyfilemanager.php (therefore I am running as root.). My directories are also set to 777 (This is a local installation behind a firewall, I don't care about security).

<!-- gh-comment-id:775086260 --> @pgram1 commented on GitHub (Feb 8, 2021): > kindly share the `$root_path` and `$root_url` config to help you on this. The full path of what I want to make the home directory is `/home/alarm/.fileserver/files/` The path where the tinyfilemanager script exists is `/home/alarm/.fileserver/tinyfilemanager.php` I tried all the configs described at my first post > # So far I have tried > * default root path > > ``` > // Root path for file manager > // use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder' > $root_path = $_SERVER['DOCUMENT_ROOT']; > > // Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder' > // Will not working if $root_path will be outside of server document root > $root_url = ''; > > // Server hostname. Can set manually if wrong > $http_host = '[some ip]'; > ``` > > * a simple change of the root path > > ``` > // Root path for file manager > // use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder' > $root_path = $_SERVER['DOCUMENT_ROOT'].'/files'; > > // Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder' > // Will not working if $root_path will be outside of server document root > $root_url = ''; > > // Server hostname. Can set manually if wrong > $http_host = '[some ip]'; > ``` > > * a simple change of the root path plus a change of the root url > > ``` > // Root path for file manager > // use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder' > $root_path = $_SERVER['DOCUMENT_ROOT'].'/files'; > > // Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder' > // Will not working if $root_path will be outside of server document root > $root_url = 'files'; > > // Server hostname. Can set manually if wrong > $http_host = '[some ip]'; > ``` > > My environment is the default PHP server, by running `sudo php -S 0.0.0.0:8080 tinyfilemanager.php` (therefore I am running as root.). My directories are also set to 777 (This is a local installation behind a firewall, I don't care about security).
Author
Owner

@prasathmani commented on GitHub (Feb 8, 2021):

a simple change of the root path plus a change of the root url - this one is right configuration, it should work

<!-- gh-comment-id:775166233 --> @prasathmani commented on GitHub (Feb 8, 2021): `a simple change of the root path plus a change of the root url` - this one is right configuration, it should work
Author
Owner

@pgram1 commented on GitHub (Feb 9, 2021):

a simple change of the root path plus a change of the root url - this one is right configuration, it should work

This doesn't work, it's in the things I tested. That's why I opened the issue

Also this seems incorrect because the files I want to host are in the files directory.

But this button
image
Tries to go to this link:
http://192.168.194.64/files/archive-renders_slow/3Deer.jpg

Which is wrong. Because my root IS files.


But also when I try

$root_path = $_SERVER['DOCUMENT_ROOT'].'/files';
&
$root_url = '';

The previews or opening files don't work.

It is described in detail in my first and second post here.

<!-- gh-comment-id:776055357 --> @pgram1 commented on GitHub (Feb 9, 2021): > > > `a simple change of the root path plus a change of the root url` - this one is right configuration, it should work This doesn't work, it's in the things I tested. That's why I opened the issue Also this seems incorrect because the files I want to host are in the `files` directory. But this button ![image](https://user-images.githubusercontent.com/30127221/107393287-4dd7e300-6b03-11eb-9416-21d594c9197d.png) Tries to go to this link: `http://192.168.194.64/files/archive-renders_slow/3Deer.jpg` Which is wrong. Because my root IS files. ------- But also when I try `$root_path = $_SERVER['DOCUMENT_ROOT'].'/files';` & `$root_url = '';` The previews or opening files don't work. It is described in detail in my first and second post here.
Author
Owner

@mneckel commented on GitHub (Oct 7, 2021):

I had the same problem and this fixed it.
I store my files at: /media/files/data/Public/AudioVisual

The key was to, in the Linux file system

// ...at html server document root
sudo mkdir files
// link my external directory to the new doc root sub-folder I created
sudo ln -s /media/files/data/Public/AudioVisual AudioVisual

Then edit the tinyfilemanager.php like this:

// Root path for file manager
// use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder'
//$root_path = $_SERVER['DOCUMENT_ROOT'];
$root_path = '/media/files/data/Public/AudioVisual';

// Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder'
// Will not working if $root_path will be outside of server document root
$root_url = 'files/AudioVisual';
<!-- gh-comment-id:937684953 --> @mneckel commented on GitHub (Oct 7, 2021): I had the same problem and this fixed it. I store my files at: /media/files/data/Public/AudioVisual ### The key was to, in the Linux file system // ...at html server document root sudo mkdir files // link my external directory to the new doc root sub-folder I created sudo ln -s /media/files/data/Public/AudioVisual AudioVisual ### Then edit the tinyfilemanager.php like this: // Root path for file manager // use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder' //$root_path = $_SERVER['DOCUMENT_ROOT']; $root_path = '/media/files/data/Public/AudioVisual'; // Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder' // Will not working if $root_path will be outside of server document root $root_url = 'files/AudioVisual';
Author
Owner

@prasathmani commented on GitHub (Oct 7, 2021):

preview will only work if files are under web directory.

<!-- gh-comment-id:937707623 --> @prasathmani commented on GitHub (Oct 7, 2021): preview will only work if files are under web directory.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tinyfilemanager#361
No description provided.