Using a relative path to access my files

Asked by:
MtKuile / 41 Points
Time:
2013-09-18 12:24 am EST
Category:
File Management
Hits:
1,302
I have a folder called "files" as a sub-folder of my root directory on the WebHostingHub file system. I am storing files in folder "files" via my PHP program. The PHP files sit in folder "public_html" which, like the "files" folder is a sub-folder and sits immediately under the root directory. So "files" and "public_html" are sister folders. They sit next to each other in the file system. My PHP code is pointing to the "files" folder as follows when it wants to store files there:

../files/

The first two dots indicate that folder "files" sits one step below the root directory.

Using this approach I do NOT succeed in placing files in the "files" folder. What am I missing here?

To ask this user for more information, please first login.

To submit an answer, please login.

ANSWERS

0

arnelc
Staff
17,314 Points
2013-09-18 12:56 am EST
Hello MtKuile,

Thanks for the question. You're asking programming specific questions that are very general. The path that you are referring is actually what we call a "relative path". You can look at the answer to this question for an explanation of relative paths: Path to files.

Check out this link for a pretty explanation of using the ".." in your paths: absolute paths vs. relative paths.

To fix the issue you're having, try being a little more explicit with the path. Instead of just putting "../files/" try making it "/public_html/files/. You can also learn more about using paths in PHP here: Referencing files in PHP or here: How to set paths in PHP.

I hope this helps to provide the information that you seek. If you have any further questions or comments, please let us know.

Regards,
Arnel C.

To submit a comment on this answer, please first login.

Want to share this Question?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!
Need More Help?

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.
}