Jump to content

file_exists on network share from an Ubuntu server


iridys

Recommended Posts

My setup: (everything on a local network)

Web server: Ubuntu Server 8.10 -- Workgroup

File server: Windows Server 2008 x64 -- domain

Test server: Win 2000 running WAMP -- domain

 

I'm trying to run the code snippet below. $file is a file on the File server above. It definitely exists.

Running the code below on the Test server works perfectly. But the file cannot be found when running from the Web server.

 

$file = '//server/share/file.txt';if (file_exists($file))echo 'yay!';elseecho 'error';

 

 

What with the safe mode considerations, I've also tried to add:

 

ini_set('safe_mode', 'Off');

to no effect. And since file, and fopen similarly not work, I'm pretty sure it's not that either.

 

The File & Test servers are on the same Windows domain, but that's definitely not the reason. I tried the code on a file on a Linux computer in the Workgroup (where the Web server is) with the same results: Test server works, Web server does not.

 

Please advise; I'm really lost.

 

Network shares use this format: \\smbserver\share\path\to\sharefile.ext

http://php.net/manual/en/wrappers.file.php

 

Windows Filesystem would probably resolve it correctly, but a nix box won't.

 

I've tried both "\" and "/". No joy either way.

Incidentally, if it's of any significance, the code works on my Test server (Win2k) only if I use "/".

I was positive I'd tried this myself when I was using nix as a desktop OS.  Anyway, I'm questioning if a Linux PHP binary would support a windows share, does PHP have an internal library for it, might it use samba libs or others, does it need to be compiled with support?  I didn't find any quick answers, damn you google!.. and PHP docs..

 

Try mounting the share and accessing it with a regular nix path, that'll most likely work.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.