I don't believe there's a feature of the FTP protocol to check if a
file/folder exists.

Can you please provide a PHP userland solution to this, so that a
corresponding C implementation could be added.

I believe the way to go about it is list the CWD contents and check if that
exists and is of type DIR. You must also make sure that if a file exists
with the name of the directory you want to check it has to handle that
properly, it can't simply return true or false. If false then that means
you could create it because it doesn't exist. If true it means you can CD
into it and put stuff there, which is also not true.

Thanks,
Paul.


On Fri, Jan 18, 2013 at 3:00 PM, Will Fitch <willfi...@php.net> wrote:

>
> On Jan 18, 2013, at 9:53 AM, KISE <wowk...@gmail.com> wrote:
>
> > Hi
> >
> > II would like to see "ftp_dir_exists()" function in PHP, right now its
> > kinda unreasonable to expect people to use hacks such as "is_dir()" and
> > having to re-authenticate just to check if the dir exists, I also dont
> > think its good idea to use "ftp_chdir()" just to check if the directory
> > exists, because its shows errors if the directory doesn't exists. i think
> > there should be a way to check if the directory exists without having to
> > resort to hackish ways, or having to authenticate again.
>
> There are procedures in place for this.  If you'd like to make a feature
> request, use bugs.php.net and submit the request with the FTP extension
> selected.  You can also use https://wiki.php.net/rfc if you really want
> to see/make the change as well.

Reply via email to