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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

765 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