Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP vs. HTTP in uploads 1

Status
Not open for further replies.

smashing

Programmer
Joined
Oct 15, 2002
Messages
170
Location
US
Just discovered the FTP functions in PHP.
I've written upload scripts using HTTP before
(i.e. copy($_FILES['img1']['tmp_name'], "../upload/" .$_FILES['img1']['name']) or die("could not copy the file.");
which has no problem other than speed. I've found that a file uploaded with a DSL connection will usually take a MB a minute.
I know that regular FTP using an FTP client uploads files much faster.
So my question is: Will a PHP script that executes the ftp_put function upload FTP speed?
 
Your metaphors are wrong.

If you want to use FTP to get files from a client to a server, then the server must be running an FTP service and the control of transmission of the file rests with the client machine.

PHP, however, runs on the server, so ftp_put() would be sending data [a]away from[/b] the server, not toward it. If you were to send data toward the server, you would invoke ftp_get().

But PHP's ftp_* family of functions require connection to an FTP server. Unless you're running an FTP server on your client machine, ftp_get() won't be able to fetch files from the client machine to the server. Even then, if your machine is on an ISP that is using network address translation, chances are you won't be able to initiate a connection from the server to the client machine.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Unless you're running an FTP server on your client machine, ftp_get() won't be able to fetch files from the client machine to the server.

That would mean it won't accept a file from the $_FILES superglobal then?
 
PHP manual is sadly lacking in this respect - ftp_get() and ftp_put() are simply listed as functions and there is no reference as far as I can see to the need for any FTP server on client machine.
 
daybase:
FTP is a client/server architecture, which means the protocol requires two parts: a client and a server. Although PHP can ask as an FTP client through the use of ftp_* functions, you can no more perform FTP operations against a machine not running an FTP server than you can perform HTTP operations against a server not running a web server.

Knowledge of this fact is, I presume, assumed in the sparseness of the documentation on these functions.

smashing:
No, it does not.

Uploading files from a web page is a function of HTTP, another client/server architectured protocol. But in this case, the web browser is the client and the web server is the server.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top