开发者

PHP / FTP Client

开发者 https://www.devze.com 2023-02-28 14:08 出处:网络
I\'m about to get my hands dirty writing an FTP wrapper for PHP, I just need to perform the basics: read / write and append to files

I'm about to get my hands dirty writing an FTP wrapper for PHP, I just need to perform the basics:

  • read / write and append to files
  • list / chmod and delete files / folders

Unfortunately I only had to mess with FTP within PHP once to answer this question, and I got somewhat d开发者_JS百科isappointed with the ftp extension, mainly because it ain't trivial to distinguish between files and folders and the overall speed wasn't great.

As far as I know PHP has four distinct ways of interacting with FTP servers:

  1. Pure Socket Implementation
  2. File Wrappers
  3. FTP Extension
  4. CURL Extension

Now, I don't want to code the FTP client protocol myself, so option #1 is out of the equation.

File wrappers are great if I need to do something trivial like getting a single file, but they are extremely slow if I need to perform more complex operations since each call will open its own connection.

That leaves me with the FTP and CURL extensions, and here is where I need some guidance. As I said before I am not a big fan of the FTP extension, on the other hand I've never used CURL to FTP so I can't objectively compare one with the other.

Has anyone ever tried both approaches? What are your thoughts on them? Is the CURL option faster?

Also, are there any alternatives I'm not aware of?


Have you looked at the PEAR package Net_FTP?


I've tried both for one proj. Was needed to upload some file via ftps+auth connection with encryption and authentication then to get response code and XML info, kind of XML-RPC exchanging so at the end could not even come closer to the solution with php-ftp-extension and everything was accomplished with some debugging (CURLOPT_VERBOSE) and configuring with PHP-CURL. So I vote for CURL, it is from 1997-th and works great!

0

精彩评论

暂无评论...
验证码 换一张
取 消