It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming HTML Forum

what does ../ mean

what does ../ mean

Postby giles100 on Mon May 14, 2007 3:47 pm

Hi!

I’ve seen ../ used a lot in filepaths. I think it’s to prevent visitors traversing up a file tree. I’ve searched around for tutorials but don’t know what it’s called, and obviously Google won’t return a search on ../ Can you help me either with a name, or URL to an appropriate tutorial.

Thanks
Giles
giles100
 
Posts: 2
Joined: Mon May 14, 2007 3:05 pm

Postby jberry on Mon May 14, 2007 4:16 pm

This is just telling a link you way have to go back two steps in that filepath so is the path is ../photo.jpg. ../ would be the file file that the file is in. I hope this explains and I hope i explained it correctly but that is what it is.
jberry
100+ Club
 
Posts: 144
Joined: Mon Mar 19, 2007 4:40 pm
Location: Atlantic City, NJ

Postby generalchaos316 on Mon May 14, 2007 10:56 pm

Jason iscompletely right. This is called a "Relative path" because you are talking about the location of a file RELATIVE to the one you are currently in. This is the preferred way of coding your site because you can move the webpage around and still have all the links/images/etc continue to work fine.

The opposite of a relative path is called an "Absolute Path." This tells the browser EXPLICITLY where the file is located. C:\webpage\image.jpg or http://www.mysite.com/image.jpg are examples of absolute paths.

As you might be able to see...absolute paths can cause problems. What if you upload your site to an internet hosting company? I'd be willing to bet your picture isn't going to wind up in C:\webpage\image.jpg (especially because they are likely to be using Linux based servers!)

Or what if you change the name of your website? Now it is http://www.mynewwebsite.com. Again, you will have to go back through all your code again and update the paths.

I tend to get the two mixed up, but think of:
../ "Current Directory"
./ "Back One Folder"

You can chain multiple ./'s together too:
./././images/image.jpg would take you backwards 3 folders in the file tree, then go into the "images" folder, and finally get image.jpeg

More reading can be done here:
http://webdesign.about.com/od/beginningtutorials/a/aa040502a.htm
generalchaos316
100+ Club
 
Posts: 101
Joined: Fri Mar 16, 2007 6:01 am


Who is online

Users browsing this forum: No registered users and 4 guests