Convert Relative to Absolute Path

Hello everyone,

I am attempting to convert a relative file path to an absolute file path. I have input of path = 'text.txt'. I need to be able to determine the absolute path of 'c:/site/text.txt'.

The os.path.abspath method doesn't work since it takes the current working directory path. os.path.realpath does the same thing. I've also tried changing the current working directory, but that doesn't really do anything unless I have the full path to begin with.

I am doing this for a web server. I don't want users to have to enter the full path of the files they want to retrieve. Instead, I want to be able to navigate to the file manually if it exists.

Well, I didn't get an exact solution as to what I mentioned above. However, I did come up with a compromise. As long as the files are located in the root or sub directory of the root server, then this code will work.