|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[1999-06-12 16:41 UTC] jim at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 17 10:00:01 2025 UTC |
Using any of the PHP functions to read a file via an FTP URL (fopen, readfile, etc) may fail if the remote FTP server is operated by NcFTP Software's NcFTPd server (v.2.3.2 and below). Running PHP 3 as an Apache 1.3.3 module, the connection fails because the server doesn't accept the SIZE command while in ASCII file transfer mode (which is the default selected mode using the above combination of OS/HTTP server/PHP module). If the transfer mode is set to BINARY the command is understood and the file transfer takes place. Since the php3_fopen_url_wrapper() function in fopen_wrappers.c file switches anyway to binary transfer mode before sending the PASV command, but after having sent the SIZE command, changing the order of FTP commands from: SIZE TYPE I PASV to: TYPE I SIZE PASV would cure the NcFTPd mis-functionality. This has already been successfully tested modifing the fopen_wrappers.c file in the following way: ... /* set the connection to be binary */ SOCK_WRITE("TYPE I\n", *socketd); result = _php3_getftpresult(*socketd); if (result > 299 || result < 200) { free_url(resource); SOCK_FCLOSE(*socketd); *socketd = 0; return NULL; } /* find out the size of the file (verifying it exists) */ SOCK_WRITE("SIZE ", *socketd); SOCK_WRITE(resource->path, *socketd); SOCK_WRITE("\n", *socketd); ... --- Tested case Having the URL ftp://ftp.server.mydomain/thefile in a readfile() function, with ftp.server.mydomain being an NcFTPd FTP server: ftp> ascii 200 Type okay. ftp> size /thefile 502 Not implemented for TYPE A. ftp> binary 200 Type okay. ftp> size /thefile 213 481