Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
03-07-2008, 02:22 PM #1
file_exists not working over secure ftp.
I have encountered a problem with file_exists when running PHP 5.2 in client mode under Debian Etch, which is best illustrated by the following code:
$remote_dir = "ftps://username:firstname.lastname@example.org:21/";
$list = scandir($remote_dir);
foreach ($list as $entry)
echo $remote_dir.$entry.(file_exists($remote_dir.$entry) ? " exists": " not found")."\n";
ftps://usename:email@example.com:21/file1.php not found ftps://usename:firstname.lastname@example.org:21/file2.php not found ftps://usename:email@example.com:21/file3.php not found ... etc
EDIT: I've found that scandir, is_dir and unlink work, however file_exists, is_file, is_readable and stat don't work. Weird.
Last edited by mlse; 03-07-2008 at 02:30 PM. Reason: More experimentation
03-07-2008, 02:37 PM #2
- Join Date
- Oct 2006
- Denver, Colorado USA
- Thanked 476 Times in 465 Posts
Turn on full php error reporting to see if any errors are occurring.
For your code to work, two things must happen. PHP must have the OpenSSL extension enabled so that it can make a request using the ftps protocol, and the ftps wrapper must support scandir().
From the php manual it is not clear if scandir() is supported. Table O.4 does not specifically list scandir(), but it would probably fall under the stat() functions, where only the following are supported - As of PHP 5.0.0: filesize(), filetype(), file_exists(), is_file(), and is_dir() elements only. As of PHP 5.1.0: filemtime().Finding out HOW to do something is called research, i.e. keep searching until you find the answer. After you attempt to do something and cannot solve a problem with it yourself, would be when you ask others for help.
Users who have thanked CFMaBiSmAd for this post:
03-07-2008, 02:42 PM #3
thanks for that! I will investigate my set-up more fully ... in the meantime I've written a hack using fopen and fclose.