Clemenz Clemenz - 4 months ago 18
PHP Question

PHP ftp_delete() generates warning "Command okay"

I can not find any answer to this as most problems revolve around a file not existing or a delete process not working.

I have an FTP device where I generate a file with an PHP script. After that, I try to FTP in, get the file and after that, delete it.

This all works fine, I can connect, get the file and save it locally and then delete it. Except for one thing, the

ftp_delete()
function results in a warning.

PHP gives me the following, when executing the script:


A PHP Error was encountered

Severity: Warning

Message: ftp_delete(): Command okay


I looked up the error code, it means it was successful. And it was because the file is deleted on the FTP device.

So why does this generate an PHP error?

Cheers.

Answer

The RFC 959 (FTP specification) mandates that on a successful completion of the DELE command, the server should respond with 250 status code.

The PHP FTP implementation is very strict, yielding a warning on any other code, even if it indicates a success (2xx class).

Your server probably uses some other 2xx code, like a generic 200 Command okay.