Question

I am using my own server running Windows Server 2008 and IIS v7.5. The OS is on the c: drive along with the website. I have a number of photos and videos with associated text files which are currently also on the c: drive (see simplified structure below) which I wish to move to a larger d: drive on the same server.

OS(C:)
- inetpub
--- wwwroot
----- albums
------- index.html
------- xxx.php
------- etc
------- info
---------- textfile1.txt
---------- textfile2.txt
---------- etc
------- photos
---------- photo1.jpg
---------- photo2.jpg
---------- etc

I currently output the text files and photos using a 'for' loop within PHP which simplified look like:

include 'info/textfile1.txt';
img src = 'photos/photo1.jpg' alt = "photo1.jpg" width="200px"

which both work.

Prior to moving the files to the d: drive I have expanded these to absolute pathnames:

include 'C:/inetpub/wwwroot/albums/info/textfile1.txt';
which works, and

img src = 'C:/inetpub/wwwroot/albums/photos/photo1.jpg' alt = "photo1.jpg" width="200px"

which does not work (just displays the 'alt' text).

To be absolutely clear, all of these files are on the server.

So,
1. Why doesn't the img src with full pathname work and how do I get it to work?
2. Is there any security (or other) risk with this approach?

Was it helpful?

Solution

It will never work
"img src" works in client's browser, which doesn't have access to the server's directory structure and files below the c:/inetpub/wwwroot directory.
Absolute paths in "img src" can only be "http://domain.com/folder/file.ext", like that

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top