tags:

views:

55

answers:

2

Hi all,

I'm making a small app that must check if a certain file exists in the client computer.

$file = "C:\\Windows\\System32\\rpnt.dll";

if (is_file($file)){
 echo $file . " exists";
}else{
 echo $file . " does not exist";
}

Can't make this work. Any solution out there?

A: 

Try using forward slashes (/) instead of backslashes for the directory separator character. I've occasionally had trouble with PHP getting confused with backslashes in Windows file paths.

theomodsim
The only time I've ever had an issue with backslashes in the path are for network names `\\server\path` vs `//server/path`... With regular directories, I've never seen an issue (And I primarily work on Win32 environment)...
ircmaxell
Already tried that, no go.
jaclerigo
+6  A: 

PHP is server side, you cannot check to see if a file exists on the client with it. Nor could you do it with javascript or almost any other client-side technology... for obvious security reasons.

The reason it's not working is because it's checked to see if 'C:\Windows\System32\rpnt.dll' exists on the server and you are probably using a linux based operating system for your web server...

Kane Wallmann
I didn't explained it right, but this app is running locally with WAMPSERVER in a Win32 system.
jaclerigo
Sorry for assuming buddy, you did say 'client computer'. Does it work for files within your document root? If so I would be lead to believe it is a problem with permissions. However, with my stock installation of WAMP is_file seems to work fine with files in my system32 directory. :S
Kane Wallmann