Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder mlse's Avatar
    Join Date
    Mar 2005
    Posts
    624
    Thanks
    20
    Thanked 19 Times in 18 Posts

    file_exists not working over secure ftp.

    Hi all,

    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:

    PHP Code:
    $remote_dir "ftps://username:password@127.0.0.1:21/";
    $list scandir($remote_dir);

    foreach (
    $list as $entry)
      echo 
    $remote_dir.$entry.(file_exists($remote_dir.$entry) ? " exists"" not found")."\n"
    Now the output from this is as follows:

    Code:
    ftps://usename:password@127.0.0.1:21/file1.php not found
    ftps://usename:password@127.0.0.1:21/file2.php not found
    ftps://usename:password@127.0.0.1:21/file3.php not found
    ... etc
    ¿Que?

    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

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,019
    Thanks
    2
    Thanked 313 Times in 305 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().
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • Users who have thanked CFMaBiSmAd for this post:

    mlse (03-07-2008)

  • #3
    Regular Coder mlse's Avatar
    Join Date
    Mar 2005
    Posts
    624
    Thanks
    20
    Thanked 19 Times in 18 Posts
    Ok,

    thanks for that! I will investigate my set-up more fully ... in the meantime I've written a hack using fopen and fclose.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •