|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-01-22 15:57 UTC] dtajchreber@php.net
-Assigned To:
+Assigned To: dtajchreber
[2013-01-22 15:57 UTC] dtajchreber@php.net
[2017-10-24 07:10 UTC] kalle@php.net
-Status: Assigned
+Status: Open
-Assigned To: dtajchreber
+Assigned To:
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 19:00:02 2025 UTC |
Description: ------------ I think PHP needs proper way to check if the FTP directory exists, right now there is no correct way to do it other then using ftp_chdir/is_dir and check the results which produce E_WARNING if the directory doesn't exists. there is also is_dir() function which require that you re-authenticate just to check if the directory exists and if you have to check multiple directories you have to re-authenticate each time. i hacked this function in "test script" just to bypass the E_WARNING Test script: --------------- function dir_exists2($conn, $dir) { $orginal = $dir; if ( !$conn ) return false; if ( substr($dir, -1) === '/' ) $dir = substr($dir, 0, strlen($dir)-1); $dir = substr($dir, 0, strlen($dir)-strlen(strrchr($dir,'/'))); $res = ftp_nlist($conn, '-dF '. $dir); if ( isset($res) AND is_array($res) ) { foreach ($res as $key => $value) { if ($value === $orginal) return true; } } return false; } Expected result: ---------------- true if directory exists and false if it does not exists.