file_exists( ) + Mapped network drives - PHP ***HELP ME, URGENT***

Posted on 2003-02-21
Medium Priority
Last Modified: 2012-08-14
Ok, why this won't work? I want to check if file_exists on mapped drive. I have tried several ways and readed php manual but can't get it work.

I have tried for example these:
(aslo tried without "getcwd()")

if (file_exists (getcwd()."W:\folder1\folder2\file.txt"))
Header("Location: W:\folder1\folder2\file.txt");

if (file_exists (getcwd()."W:\\folder1\\folder2\\file.txt"))
Header("Location: W:\\folder1\\folder2\\file.txt");

if (file_exists (getcwd()."W:/folder1/folder2/file.txt"))
Header("Location: W:/folder1/folder2/file.txt");

if (file_exists (getcwd()."W://folder1//folder2//file.txt"))
Header("Location: W://folder1//folder2//file.txt");

if (file_exists (getcwd()."//computername/folder1/folder2/file.txt"))
Header("Location: //computername/folder1/folder2/file.txt");

If I put those in <A HREF=" ">link</A> some will work. In link those will work but PHP can't find the file from mapped network drive... why?

Question by:excinc

Expert Comment

ID: 7992603
you can not mapp to a local drive like this. The browser accepts only urls. (localhost i.e)


Expert Comment

ID: 7993651
Remember that, like Oliver noted, you can only use URLs. Such as:


The only way you can check on files existing is if they're in the webserver directory (or subdirectory).

If you could map a network drive to a folder in one of those directories, that would work (though I don't even know if its possible and that would be a godawful security risk).

Short Answer: No.

Long Answer: Too much of a security risk to bother with.

I would suggest another language for this, perhaps javascript. PHP won't do what you're looking for here.

Accepted Solution

s-maxim earned 80 total points
ID: 7999294

Why not simply use include() function?

All you need is to display the content of that page to the user, right? Since it is outside the webroot, you can only include it.


if (file_exists (getcwd()."W:\\folder1\\folder2\\file.txt")) {

Maxim Maletsky

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question