473,785 Members | 2,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[Q] obtaining relative paths within a html page?




I have a root directory with 1 subdirectory(my photo), and 2 files.
Inside the myphoto subdirectory, I have 1 html page and another image.

Root dir:
<myphoto>
01.jpg
watermark.php
myphoto:
indexpage.html
01.jpg
Inside indexpage.html, I have a link like this, which calls the
watermark.php in the root directory and passes it a parameter of a
filename.

<a href="../watermark.php?s rc=01.jpg" target="">my watermarked
image</a>
However, in this case, watermark.php is passed the 01.jpg which is in
the root directory.

Instead of this, I want it to be passed the 01.jpg from the myphoto
subdirectory. I can solve the problem easily if I code in the absolute
path, but I want
to stay with relative paths, since I may change directory names quiet
often.

How can I solve this problem?
Jul 23 '05 #1
3 1601
On Wed, 09 Feb 2005 00:57:33 GMT, te**@gesg.com (Sir Loin of Beef)
wrote:
I have a root directory with 1 subdirectory(my photo), and 2 files.
Inside the myphoto subdirectory, I have 1 html page and another image.

Root dir:
<myphoto>
01.jpg...


[bla, bla bla]

And this relates to an (X)HTML problem of yours in some way?

--
Rex
Jul 23 '05 #2
Previously in comp.infosystem s.www.authoring.html, Sir Loin of Beef
<te**@gesg.co m> said:
<a href="../watermark.php?s rc=01.jpg" target="">my watermarked
image</a>

However, in this case, watermark.php is passed the 01.jpg which is in
the root directory.

Instead of this, I want it to be passed the 01.jpg from the myphoto
subdirectory. How can I solve this problem?


Change your php code to look in the myphoto directory for the filename
you pass it. Then if you ever change the directory, you only have to
change it in the php, rather than on every link.

--
Mark Parnell
http://www.clarkecomputers.com.au
Jul 23 '05 #3
Sir Loin of Beef wrote:
to stay with relative paths, since I may change directory names quiet
often.


Why would you ever want to change your directory paths so often? Doing
so is very likely to also change the URI, which is very bad practice.
Have you not heard that Cool URIs Don't Change? Think before you
publish and directories won't need to change.

http://www.w3.org/QA/Tips/uri-choose
http://www.w3.org/QA/Tips/uri-manage
http://www.w3.org/Provider/Style/URI

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://SpreadFirefox.com/ Igniting the Web
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4113
by: jason | last post by:
Can anyone help me find a solution to quickly working out relative paths to a folder in the root of my server... Although it easy when you go - say - two levels down: .../includes it becomes increasingly difficult to ball park the folder when you go deeper and wider down:
15
2909
by: Nick K. | last post by:
I recently began maintenance work on a production web server that is located in the root directory of a web server. I moved this into a sub web on my local web server in order to do work on it. I found that there is an include file that references images: <img src = "/images/Header.gif" What worked correctly on the production server breaks on mine because of the absolute address "/images". I removed the absolute address and changed...
3
2677
by: epigram | last post by:
I've got a javascript menu that uses an external .js file. In the .js file, there is a function that gets called by each of my .html pages to build up the menu for the page. The way I want to structure my site is to put my main index.html file in the root folder, and then have subdirectories for various logical sections of my site that will contain related .html files. I was hoping that the paths in the .js file would be relative to the...
2
2370
by: Alex | last post by:
Hi. I need some help on this. I have a user control (a header) in my root directory, and all my pages use that control. Then a created a folder (in my root directory) and put a new page inside it, and that page use the same control, but this time the control can't find it's images and resources because it is trying to find it in the same folder instead of the root directory. Now, I know that I can change the control image's relative paths...
2
1880
by: Steve Franks | last post by:
I am familiar with the fact that you have to use runat=server and links staring with "~/" to ensure proper mapping of paths to relative URLs when using master pages. However this does not seem to work in all cases. For instance, assume I have a "/mysite/images" subdirectory with mybackground.gif and mygif.gif in there. Further assume I have a master page called mastertest.aspx located in /mysite/myfolder".
11
2270
by: MBS | last post by:
I am playing around with some PHP code. I want to put in an include() function so I can include existing HTML code and output it to the browser. Lo and behold PHP does not support relative paths with the include() function! (How shortsighted can you get?) Is there any way at all to use relative paths with include()? Any hacks? If I use an absolute filepath, everything is fine. But I don't want to do that--I can't do that. I want...
3
12853
by: yan | last post by:
Hello everybody, I am new so this is the occasion to say hello to everybody. I have a problem with absolute/relative paths. I have to create a static documentation in html for a project and I have to create an index page in every sub-directory. The structure is like the following: / /sources/ /docs/ /docs/doc1 /share
1
2355
by: Anees | last post by:
hi i was trying to implement mode rewrite option in a blog site. i used the lines for listing the posts by its topic category as #List by Category RewriteRule ^Topics/(+)$ index.php?cat=$1 #With page navigation option RewriteRule ^Topics/(+)/(*)$ index.php?cat=$1&start=$2
15
6471
by: Lars Eighner | last post by:
Aside from the deaths of a few extra electrons to spell out the whole root relative path, is there any down side? It seems to me that theoretically it shouldn't make any difference, and it would make it much easier to slap modualar blocks of markup into page frameworks, which may change and so forth. And the few extra bytes, which even for a fairly large site would not amount to as many bytes as are in a fairly small low-res image, should...
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10087
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.