Resolving Windows virtual directory paths

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nmw
Forum Newbie
Posts: 5
Joined: Tue May 30, 2006 3:19 am

Resolving Windows virtual directory paths

Post by nmw »

Can't work out how to do this. It may be specific to Windows.

I have a large (MySQL) database of photo images on a PC server running IIS. The image information is in the database, the images themselves are on a separate Windows drive (I:) in a set file structure that the PHP code can navigate from the image information. Since the webroot is the usual c:\inetpub\wwwroot, and the images are elsewhere (I:), there is a virtual directory set up in IIS to allow access from the web root (ie the virtual directory 'dbimages' actually points to I:\dbimages).

So far, so good. All works fine. The virtual directory references all work correctly in the generated web pages.

However one of the things the PHP code needs to do is physically copy images from their location on I:. I do this using the PHP copy() function. However, copy() will NOT resolve a virtual directory path. Ie the path './dbimages/x/y/z/thisimage.jpg' which works fine in the webpages does not work as the source reference for copy, it has to be 'I:/dbimages/x/y/z/thisimage.jpg' instead. This means that the true drive location, I:, needs to be hardcoded, or at least explicitly user settable, for the PHP code.

So my question is this: is there a way of resolving a virtual directory path to a true physical path on the machine on which it is running?
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Resolving Windows virtual directory paths

Post by andyhoneycutt »

Have you tried something like the following? I think the virtual directory should resolve as being under the web root:

Code: Select all

$virtual_file_path = "C:\\inetpub\\wwwroot\\dbimages\\x\\y\\z\\thisimage.jpg";
If that's not going to work, have you tried using something like file_get_contents to open an http: connection and saving the file, such as:

Code: Select all

$image_data = file_get_contents("http://my.website.here/dbimages/x/y/z/thisimage.jpg");
$fp = fopen($path_to_save_image_to,"w");
fputs($fp,$image_data);
fclose($fp);
Or some other variation of file i/o.

-Andy
Post Reply