I have this doubt because time is only necessary the path pasta/arquivo.ext
and time I have to put ../pasta/arquivo.ext
.
Is there a rule?
I have this doubt because time is only necessary the path pasta/arquivo.ext
and time I have to put ../pasta/arquivo.ext
.
Is there a rule?
Of course, there is a rule, imagine that you are declaring the path to the one.jpg
image in the index.php
file within the following structure:
-index.php
-imgs
- one.jpg
- two.jpg
...
For this case above you would use this:
imgs/one.jpg
Another case will be:
-views
- index.php
-imgs
- one.jpg
- two.jpg
Now you would have to declare that you want to go back 1 level ( ../
) in the folder hierarchy, where the starting point is index.php
itself, thus:
../imgs/one.jpg
That is, with this "declaration" ( ../
) you are at views
and imgs
level, then yes, you can enter imgs
and complete the path with the image you want, and same goes for longer path:
-public
-views
- index.php
-assets
-imgs
- one.jpg
- two.jpg
Here you would have to go back two levels in the structure so that you can "enter" the folder assets
and have access to imgs
and then to the image, ../../assets/imgs/one.jpg
All of these uses involve using the relative path , rather than < a href="http://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/"> absolute path