PHP 页面上的文件树使用框架?

发布于 2024-10-04 14:30:46 字数 562 浏览 0 评论 0原文

我目前有一个 php 网页。但是,我想将其分为两部分,并在页面左侧有一个文件浏览器。我希望浏览器像一棵树,以便用户可以深入到文件夹。

当用户向下浏览到文件并在左侧单击它时,我希望将该路径 /dir1/dir2/file 加载到我的右侧的文本框中PHP 页面。

有人可以建议去做这个吗?我真的感到不知所措,压力太大而无法开始。我正在网上查看文件树程序,我遇到了付费程序,我无法与现有页面集成,因为它们几乎是文件/上传浏览器!我只想拥有一个树结构,而不允许用户重命名/上传

这就是我看到页面完成的方式:

==========================
File Tree | Actual Page  |
File Tree | Actual Page  |
File Tree | Actual Page  |
File Tree | Actual Page  |
File Tree | Actual Page  |
File Tree | Actual Page  |
File Tree | Actual Page  |
==========================

I currently have a php webpage. However, I want to break it down into two sections and have a file browser on the left hand side of the page. I want the browser to be like a tree , so that a user can go deep into folders.

When a user browses down to a file and clciks it on the left side, I want that path /dir1/dir2/file to be loaded onto a text box that I have on the right hand side of my PHP page.

Can someone recommend going about this? I really feel overwhelmed and am too stressed out to begin. I was looking at file tree programs online and I come across paid one's or one's that there is no way I could integrate with my existing page, since they are pretty much file/upload browsers! I just want to have a tree structure without allowing the user to rename/upload

This is how I see the page being completed :

==========================
File Tree | Actual Page  |
File Tree | Actual Page  |
File Tree | Actual Page  |
File Tree | Actual Page  |
File Tree | Actual Page  |
File Tree | Actual Page  |
File Tree | Actual Page  |
==========================

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挥剑断情 2024-10-11 14:30:47

有几种方法可以解决这个问题。一种方法是在一个 iframe 中显示文件浏览器,并在另一个 iframe 中显示文件。

filebrowser.php 源代码基本上如下所示:

$dir = $_GET['dir'];

// validate $dir to make sure it's viewable by the current user!

$contents = scandir($dir);
foreach ($contents as $c) {
  $subfile = $dir.'/'.$c;
  if (is_dir($subfile) {
    echo "<a href=\"filebrowser.php?dir=".urlencode($subfile)."\" target=\"filebrowser_iframe\">$c</a><br>";
  } else {
    echo "<a href=\"filedisplay.php?file=".urlencode($subfile)."\" target=\"filedisplay_iframe\">$c</a><br>";
  }
}

在 filedisplay.php 中

$file = $_GET['file'];

// validate $file to make sure it's viewable by the current user!

readfile($file);

There are several ways you could go about this. One way would be to have the file browser in an iframe and the file display in another iframe.

The filebrowser.php source would look very basically like this:

$dir = $_GET['dir'];

// validate $dir to make sure it's viewable by the current user!

$contents = scandir($dir);
foreach ($contents as $c) {
  $subfile = $dir.'/'.$c;
  if (is_dir($subfile) {
    echo "<a href=\"filebrowser.php?dir=".urlencode($subfile)."\" target=\"filebrowser_iframe\">$c</a><br>";
  } else {
    echo "<a href=\"filedisplay.php?file=".urlencode($subfile)."\" target=\"filedisplay_iframe\">$c</a><br>";
  }
}

In filedisplay.php

$file = $_GET['file'];

// validate $file to make sure it's viewable by the current user!

readfile($file);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文