php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #36423 Suggestion for FTP functions
Submitted: 2006-02-16 22:07 UTC Modified: 2006-02-17 18:08 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: bholbrook at servillian dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 4.4.2 OS: Red Hat v?
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bholbrook at servillian dot com
New email:
PHP Version: OS:

 

 [2006-02-16 22:07 UTC] bholbrook at servillian dot com
Description:
------------
Suggestion for additional FTP functions

ftp_is_dir(), ftp_file_exists(), ftp_is_file().

Currently can be accomplished by

if(!ftp_chdir()), if(!ftp_mdtm())

but has some effects on true that can cause additional coding. Sorry if this is the wrong place for it (please let me know where to send these so that I dont repeat this mistake)

Thanks.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-17 18:08 UTC] bjori@php.net
These can easily be emulated in userspace as is.

function ftp_file_exists($ftp, $file) {
    $tmp = ftp_nlist($ftp, $file);
    return is_array($tmp) ? true : false;
}
function ftp_is_dir($ftp, $dir) {
    return @ftp_chdir($ftp, $dir. "/..");
}
function ftp_is_file($ftp, $file) {
    $tmp = ftp_nlist($ftp, $file);
    return is_array($tmp) && count($tmp) == 1 ? true : false;
}

If this were to be implemented at extension level the code would probably do the exact same thing.

Can't see any reason to implement it.
 [2010-07-07 12:38 UTC] moritz at pflanzer dot eu
The suggested method to emulate ftp_is_file() does not work correctly!
Imagine you check a path linking to an directory with only one file in it then the function would return true although the path belongs to an directory.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 11:01:30 2025 UTC