[GH-ISSUE #633] Pass a url parameter to tinyfilemanager for adding subfolder to root_path #451

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

Originally created by @gthurmon on GitHub (Sep 24, 2021).
Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/633

I want to be able to pass a dynamic variable in the URL string
like https:\xxxx.com\tinyfilemanager.php?subdir=2070
where '2070' is a subfolder of \rfq_documents\ i.e. \rfq_documents\2070 is a real folder.
BTW there are over 6,000 subfolders under \rfq_document\

This does not work:
// Get url [subdir] parameter passed to this script
$newpath = $_GET['subdir'];
$thissubdir = '/rfq_documents/'.$newpath;

// Root path for file manager
// use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder'
$root_path = $thissubdir; //this just opens '/rfq_documents' as if $newpath is empty.

$root_path = 'rfq_documents/2070'; // hard coding works just fine, but I need a dynamic variable here to replace '2070'.
$root_path = 'rfq_documents'/.$newpath; // does not work treats $newpath as empty.
$root_path = 'rfq_documents'/.$_GET['subdir']; // does not work treats as empty.
$root_path = $thissubdir; // does not work treats as '/rfq_documents/'.

Can some please help. I have almost no experience with PHP. What am I doing wrong here.

Thanks

Originally created by @gthurmon on GitHub (Sep 24, 2021). Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/633 I want to be able to pass a dynamic variable in the URL string like https:\\xxxx.com\tinyfilemanager.php?subdir=2070 where '2070' is a subfolder of \rfq_documents\ i.e. \rfq_documents\2070 is a real folder. BTW there are over 6,000 subfolders under \rfq_document\ This does not work: // Get url [subdir] parameter passed to this script $newpath = $_GET['subdir']; $thissubdir = '/rfq_documents/'.$newpath; // Root path for file manager // use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder' $root_path = $thissubdir; //this just opens '/rfq_documents' as if $newpath is empty. $root_path = 'rfq_documents/2070'; // hard coding works just fine, but I need a dynamic variable here to replace '2070'. $root_path = 'rfq_documents'/.$newpath; // does not work treats $newpath as empty. $root_path = 'rfq_documents'/.$_GET['subdir']; // does not work treats as empty. $root_path = $thissubdir; // does not work treats as '/rfq_documents/'. Can some please help. I have almost no experience with PHP. What am I doing wrong here. Thanks
Author
Owner

@EV-soft commented on GitHub (Sep 24, 2021):

Try change:
$root_path = 'rfq_documents'/.$newpath;
To:
$root_path = 'rfq_documents/'. $newpath;
(/ is part of the path-string)

<!-- gh-comment-id:926668962 --> @EV-soft commented on GitHub (Sep 24, 2021): Try change: `$root_path = 'rfq_documents'/.$newpath; ` To: `$root_path = 'rfq_documents/'. $newpath; ` (/ is part of the path-string)
Author
Owner

@gthurmon commented on GitHub (Sep 24, 2021):

Sorry that was just a typo there in the question.
This still does not work for me. It is as if the $_GET is not getting so $newpath is an empty string.
$newpath = $_GET['subdir'];
$thissubdir = '/rfq_documents/'.$newpath;
$root_path = '/rfq_documents/'. $newpath;
and the URL string is getting rewritten as ...php?p=

This script woorks on the same server. Just not in tinyfilemanager.php
<?php // Get url [subdir] parameter passed to this script $newpath = $_GET['subdir']; $root_path = '/rfq_documents/'. $newpath; echo $root_path; ?>

<!-- gh-comment-id:926683327 --> @gthurmon commented on GitHub (Sep 24, 2021): Sorry that was just a typo there in the question. This still does not work for me. It is as if the $_GET is not getting so $newpath is an empty string. $newpath = $_GET['subdir']; $thissubdir = '/rfq_documents/'.$newpath; $root_path = '/rfq_documents/'. $newpath; and the URL string is getting rewritten as ...php?p= This script woorks on the same server. Just not in tinyfilemanager.php `<?php // Get url [subdir] parameter passed to this script $newpath = $_GET['subdir']; $root_path = '/rfq_documents/'. $newpath; echo $root_path; ?> `
Author
Owner

@gthurmon commented on GitHub (Sep 24, 2021):

BTW:
rfq_document is a virtual directory on the site's root.
PHP version is 7.4.13
Windows 20019 Server using IIS
I am missing something very simple here or this is way over my head.

<!-- gh-comment-id:926691322 --> @gthurmon commented on GitHub (Sep 24, 2021): BTW: rfq_document is a virtual directory on the site's root. PHP version is 7.4.13 Windows 20019 Server using IIS I am missing something very simple here or this is way over my head.
Author
Owner

@prasathmani commented on GitHub (Sep 24, 2021):

try this, add condition checks if needed

// always use ?p=
if (!isset($_GET['p']) && empty($_FILES)) {
    fm_redirect(FM_SELF_URL . '?p=&subdir='.$_GET['subdir']);
}
<!-- gh-comment-id:926727984 --> @prasathmani commented on GitHub (Sep 24, 2021): try this, add condition checks if needed ```php // always use ?p= if (!isset($_GET['p']) && empty($_FILES)) { fm_redirect(FM_SELF_URL . '?p=&subdir='.$_GET['subdir']); } ```
Author
Owner

@gthurmon commented on GitHub (Sep 24, 2021):

That works great for the initial display, but if I click on a file or folder it brings up all the files under the root of /rfq_docments/.
And the URL goes back to ........com/tinyfilemanager.php?p=

<!-- gh-comment-id:926767768 --> @gthurmon commented on GitHub (Sep 24, 2021): That works great for the initial display, but if I click on a file or folder it brings up all the files under the root of /rfq_docments/. And the URL goes back to ........com/tinyfilemanager.php?p=
Author
Owner

@prasathmani commented on GitHub (Sep 25, 2021):

add $_GET['subdir'] params to following lines
image
image

<!-- gh-comment-id:927004975 --> @prasathmani commented on GitHub (Sep 25, 2021): add `$_GET['subdir']` params to following lines ![image](https://user-images.githubusercontent.com/11345598/134756877-e69f56eb-1e66-4d49-8261-dd87ae442478.png) ![image](https://user-images.githubusercontent.com/11345598/134756894-f7d958dc-adbf-4d82-a588-1d9c4cd522f9.png)
Author
Owner

@gthurmon commented on GitHub (Sep 25, 2021):

Prasath,
First I would like to thank you for helping me with this. The latest Microsoft patch has broke IE and I was using <iframe name="I5" src="file://cfserver/rfq_documents$/#rfq.id#" to bring up windows explorer to manage file for each RFQ.
It is on our intranet and work well enough that I did not have to write more code to manage files.

I added to these lines as suggest and it now works for hyperlinked on files, but not on folders or any link that takes you back.
Given the seer number of '?p=' there are in the script is there a way to just replace the $root_path = $_GET['subdir'];
i.e. .....com/tinyfilemanager.php?subdir=/rfq_documents/2071 and the 'p=' would be as is now any subfolder under /rfq_documents/2071/ that was selected.
Again I really can't tell you how much I appreciate your time, patience and support with this. If I could get this to work it would save me months of work redoing all those apps that use the IE in an iframe.
Greg

<!-- gh-comment-id:927129084 --> @gthurmon commented on GitHub (Sep 25, 2021): Prasath, First I would like to thank you for helping me with this. The latest Microsoft patch has broke IE and I was using <iframe name="I5" src="file://cfserver/rfq_documents$/#rfq.id#" to bring up windows explorer to manage file for each RFQ. It is on our intranet and work well enough that I did not have to write more code to manage files. I added to these lines as suggest and it now works for hyperlinked on files, but not on folders or any link that takes you back. Given the seer number of '?p=' there are in the script is there a way to just replace the $root_path = $_GET['subdir']; i.e. .....com/tinyfilemanager.php?subdir=/rfq_documents/2071 and the 'p=' would be as is now any subfolder under /rfq_documents/2071/ that was selected. Again I really can't tell you how much I appreciate your time, patience and support with this. If I could get this to work it would save me months of work redoing all those apps that use the IE in an iframe. Greg
Author
Owner

@gthurmon commented on GitHub (Sep 30, 2021):

I am still trying to get this to work. Do you have any more suggestions?

<!-- gh-comment-id:931288499 --> @gthurmon commented on GitHub (Sep 30, 2021): I am still trying to get this to work. Do you have any more suggestions?
Author
Owner

@vagelisdrivas commented on GitHub (Feb 20, 2022):

I have found the solution i think.
On line 1 put
$whatever_you_like = $_GET['p'];
On line 63:
/ 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'].'/uploads/plates/';
i used the path of all my folders

Then on line 384
// clean and check $root_path
$vagelis=$root_path.$whatever_you_like;
$vagelis = rtrim($vagelis, '\/');
$vagelis = str_replace('\', '/', $vagelis);

if (!@is_dir($vagelis))
{
echo "

".lng('Root path').""{$vagelis}" ".lng('not found!')."

";
exit;
}

<!-- gh-comment-id:1046207713 --> @vagelisdrivas commented on GitHub (Feb 20, 2022): I have found the solution i think. On line 1 put $whatever_you_like = $_GET['p']; On line 63: / 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'].'/uploads/plates/'; i used the path of all my folders Then on line 384 // clean and check $root_path $vagelis=$root_path.$whatever_you_like; $vagelis = rtrim($vagelis, '\\/'); $vagelis = str_replace('\\', '/', $vagelis); if (!@is_dir($vagelis)) { echo "<h1>".lng('Root path')."\"{$vagelis}\" ".lng('not found!')."</h1>"; exit; }
Author
Owner

@mut9bu commented on GitHub (Jul 5, 2022):

Hi @gthurmon
I am working also since weeks for this topic. Similar to you I try to pass the remote network path in the URL in a parameter. (Because each connected user wants to connect to the selected IP's network path)
Did you find a solution? I also tried the suggestions, and it works just at the initial page. If you want to go into the subdirectories I get an error "Path not found" I would be very happy if you can share your last status. I will also share with you if I have something new.

<!-- gh-comment-id:1174976143 --> @mut9bu commented on GitHub (Jul 5, 2022): Hi @gthurmon I am working also since weeks for this topic. Similar to you I try to pass the remote network path in the URL in a parameter. (Because each connected user wants to connect to the selected IP's network path) Did you find a solution? I also tried the suggestions, and it works just at the initial page. If you want to go into the subdirectories I get an error "Path not found" I would be very happy if you can share your last status. I will also share with you if I have something new.
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#451
No description provided.