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 1050011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:42:20+00:00 2026-05-16T16:42:20+00:00

I cant seem to get the realpath function to work with variables is there

  • 0

I cant seem to get the realpath function to work with variables is there a way I can fix this? When I use variables in the function it returns nothing I know the pathname works without the realpath function but I want to use the realpath function with my pathname.

realpath('./members/' . $userId . '/images/thumbs/' . $image);

Edit real route.

http://localhost/Project/members/24/images/thumbs/avatar.png
  • 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-16T16:42:20+00:00Added an answer on May 16, 2026 at 4:42 pm

    Well it isn’t finished yet, but it fits perfectly…

    Look. Your site is living in two realms at a time: A real one and a virtual one.

    For site users it’s a virtual web-server, and you must understand a very important thing about it: There are no files on a web-server. Imagine you type http://example.com/index.html in the address bar. It’s not a file nor path, but a URL, an HTTP resource. A virtual address, completely different from a regular file.

    While for you as a site developer, a web-server is a program running on the computer. This computer most likely has a hard disk and a filesystem. Your PHP script, while dealing with data or including other scripts, manipulates files on a physical disk.

    Such a difference is a very common pitfall for beginners.
    Many of them confuse a file with a hyperlink, trying to call a local file using HTTP protocol or include a file using virtual path from the web-server root.

    Moreover, there are two things that hinders proper understanding:

    • a language’s developers, who want to be “nice” and make filesystem functions work with virtual resources as well
    • a local developing PC, which lets one use a filesystem path for the virtual resource and it would work. Or even worse, to copy a file from client to server!

    Be cautious and do not let them fool you.

    Well, after all it’s not rocket science. One just has to understand these 3 matters:

    1. The difference between physical file and virtual resource.
    2. What is a root thing and what’s the difference between filesystem root and web-server root
    3. The difference between absolute path and relative one.

    The first one can be easily distinguished:

    • an HTTP resource being is requested by the client, not your program
    • a file is requested by your program while client has no way to access it

    A file belongs to filesystem. It’s a piece of data stored on hard disk. It has several attributes, such as size, modification time, owner, permissions and so on. It’s explicitly filesystem attributes, no HTTP resource has it.
    Both data files and your scripts are files, and should be treated as such. If you do something like include 'http://yoursite.com/file.php';, you’re not including PHP code as expected, but just plain HTML – the result of file.php being executed!

    If you want to read image names from directory, do not read it from http://yoursite.com/image/. It’s not a directory.

    On the other hand, HTTP resource is HTTP protocol thing. Your web-server is a daemon that listens for requests. Upon receiving a request for a particular resource identified by URI, it looks for this resource, and (if found) returns its contents accompanied by several HTTP headers.

    A web-server has its own directory structure but it is very important to understand that this directory structure is virtual. It just resembles a real filesystem but it is not a filesystem at all.
    /dir/, /dir/file.ext,/dir/whatever – while all these paths looks different, they are all the same.
    It is tricky subject but very important to understand.
    There are no files or directories in the HTTP. But just resources, which consists of headers and body.
    If you request /dir/ URI from the server, you get headers and a body.
    If you request /dir/file.ext URI from the server, you get a headers and a body.
    Every time you request something from the server, you get a headers and a body.
    The only exception possible is a response that includes headers but no body.
    While some resources may resemble files, they are not files. They have no attributes, but headers. It’s really different realm.
    Of course, most of time web-servers just find a physical file corresponding to requested URI and output it. But it’s not a file anymore but only the file’s contents, preceeded by some headers.
    Yes – that’s the difference: It’s most important to distinguish a file as a filesystem subject and it’s contents.
    If you request something that looks like as a directory, you get in reality… an HTML code! It is very important to distinguish a directory in terms of filesystem form HTML code preceded by some headers. (Of cource you can get not HTML but some binary file contents – it’s just a matter of Content-type header. Another reason not to confuse real world with virtual one)

    Conclusion:
    If you want your script to access a file directly – address it as a file. Do not call it via HTTP! (Note that your php scripts are files 😉
    If you want the same file to be accessed by a client using HTTP protocol – address it as a virtual resource.

    Next, root.

    Well, root is a root. A starting point. A place where all begins.

    Both a filesystem and a web-server have their own roots.
    On Unix systems a filesystem root is /. Note that it is not just a directory separator! If a path begins from that symbol, it’s a name of particular directory – a root one. Every other file and directory belongs to root.
    On windows system it’s quite messy (as usual). There is no common filesystem root, but separate disks with it’s own roots. It starts from the disk drive letter and a backslash: C:\ is a root of drive C.

    A web-server has it’s own root. A place where virtual world meets real one. From the server’s point of view, web-server root (often called DOCUMENT_ROOT) is a filesystem directory, where the web-server looks for the files representing HTTP resources. For the client it’s full qualified root – a place where the web-site begins. It looks like Unix-system root – /. Client knows nothing of server’s filesystem. For the client this / is the only root.

    Conclusion:
    Always know where your root is.
    For the web-server it’s simple: It’s always /.
    For the filesystem know the point where virtual root meets real world – a DOCUMENT_ROOT. It will help you to find your own files.

    Absolute and relative paths.

    That’s simple.
    Actually, only absolute paths are real. While relative ones are imaginable and every relative path always translates into abaolute one before use.
    An absolute path is inseparably linked with root. As a matter of fact, an absolute path is a path that built from the root:

    • /var/www/site/forum/index.php
    • с:\windows\command.com
    • /img/frame.gif

    As you can see, the first two are filesystem paths, from unix and windows respectively, while the third one can’t be clearly defined, but is most likely a virtual HTTP resource.

    Every path which includes no root directoctory is a relative one. It builds up from the current location:

    • file.php
    • ./file.php
    • images/picture.jpg
    • ../file.php
    • ../../file.php

    Conclusion:
    Always use absolute paths when possible. It’s unambiguous and works everywhere, regardless of current directory. It may contain variable part, to let it work in different environments, but at the end it should be always absolute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cant seem to get this to work, It returns Null SELECT sdt, timeFor,
I cant seem to get this to work. http://www.keironlowe.host56.com What I need is the
I cant seem to get CI2's captcha helper to work... Can someone point out
Hey guys I cant seem to get this to work: div.Attributes.Add(UserFriendsWall.aspx?FriendID= + Server.UrlEncode(id)); Also
I can't seem to get it to work. It works fine in Firefox, but
I can't seem to get it to work. Perhaps I'm not even testing it
I can't seem to get a custom action working. I might be doing this
I can't seem to get the wsgiref module to work at all under Python
I cant seem to get this working, i need to display the Total Order
I cant seem to get my head around how to create this Each Bold

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.