Displaying folders and making links of those folders

前端 未结 1 340
终归单人心
终归单人心 2021-01-27 17:06

I am looking to build a directory browser in PHP. I have just started my code, but need someone to help me complete or modify it.

$dir = dirname(__FILE__); //pat         


        
1条回答
  •  借酒劲吻你
    2021-01-27 17:42

    While you develop this, its important to recognize that you are dealing with two different directory paths. One path is URL based, the other is Document based. The path / would take you to the root of your site where C:\some path\www\ would also take you there. Both of these reference the same location, using different means.

    With that said, you're going to have to use URL based paths the navigate your interface (unless you don't care about exposing your document path - SECURITY RISK), but the code needs to take what you've clicked and convert it to Document based paths. Here are some PHP functions which might help.

    __FILE__ - gives you the document path to the current PHP file
    __DIR__ or dirname(__FILE__) - gives you the document path to the folder the current file is at    
    getcwd() - gets the current working directory
    

    Also, instead of having the link go to the file path, have it post the file path and reload the page based on the posted data.

    Folder A Folder B

    0 讨论(0)
提交回复
热议问题