Hi...
I want to find out whether a file is existing or not
The file is stored on another machine in the same network .
I tried the following code.But always showing "The file is not existing".

<?php $filename = 'file://192.168.0.15/E:/PDF/p.pdf';

if (file_exists($filename))
 {
   echo "The file $filename exists";
} else
 {
   echo "The file $filename does not exist";
}
?>

Does anyone know how to do this?

Recommended Answers

All 4 Replies

Hi divyakrishnan,

for me it seems as if you're using Windows. Simply try

$file='\\\\\\\\HOSTNAME\\file.txt';

. As I'm mainly using Unix, I don't know exactly how the address-structure looks like in a Windows-Domain. But as long as you mask you slashes correctly, it should work perfectly when you use the address given by the explorer.

Keep in mind that this does only work, when the server let's you out of the sandbox. In real-server-mode you do get trouble. You can then install an other webserver and access the data via

$file='http://iii.iii.iii.iii/filename';

. For me that's a much cleaner solution.

Hope that helps, Simon.

I am using windows.Tried

$filename ='\\\\\\\\192.168.0.15\\E:\\PDF\\p.pdf';

still not working.

the path for windows looks like
file://///hostname/Folder/...
where Folder is the name of the folder that is shared

commented: simply true +6

Hi divyakrishnan,

you CANNOT access the complete filesystem of a remote computer! If that were possible, it'd cause a mess in security policies!

fikreyes is completely right. Have a look at basic Windows networking before trying to programme such things.

Greetings, Simon

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.