Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7018817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:06:05+00:00 2026-05-27T23:06:05+00:00

I am making a small file browsing script using PHP and Javascript and I

  • 0

I am making a small file browsing script using PHP and Javascript and I have come into a small issue. The current directory is stored as GET in the url as index.php?dir=/projects/jphp when it is in the base. I then store this in the variabe $scandir using:

$scandir = $_GET['dir'];

as the fiels are listed in a table so users can look thorugh them, folders are hyperlinked like this:

<td><a style="color: red;" href="edit.php?pid=<?php echo $project['id'] ?>&dir=<?php echo $scandir . "/" . $thisfile; ?>"><?php echo $thisfile; ?></a></td>

The variable $thisfile is populated using a foreach() loop that goes through every file in the directory.

As The user starts to browse the folders and files, the file address gets messy so, for example, after a minute of browsing the files, the $_GET['dir']; looks like

projects/jphp/js/../js/../../../projects/jphp

is there any way to keep the paths simple as the path above is the exact same as

projects/jphp

If you know how to covert the top into the bottom, that would be great, thanks! I might not have explained this well so let me know you I am not making sense.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:06:06+00:00Added an answer on May 27, 2026 at 11:06 pm

    The function realpath() does what you’re looking for. If you’re not getting any results, check your folder permissions:

    The running script must have executable permissions 
    on all directories in the hierarchy, otherwise 
    realpath() will return FALSE.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a small file-browser for my own use, in Ruby, and using Qt
I am making a small HTML page editor. The editor loads a file into
Im making a small python script to upload files on the net. The script
I'm making a small web application in Seaside. I have a login component, and
I am going to be making a small user system but I have questions.
I'm making a small tool for checking the material number from the XML file.
I am making a small website as my first project. I have finalized to
I'm making a small test framework that uses the JavaScript module pattern for UI
I´m using Mac OS Lion, with java version 1.6.0_26 I'm making a small app
Im making a (small) site in php & mysql. The mysql database consists of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.