Paul Paul - 1 year ago 112
PHP Question

Uploading file through FTP using PHP

I'm curious how to upload file through FTP using PHP. Let's say I have upload form and user have uploaded a file. How to transfer the file (without moving from temp directory) to some FTP host using PHP?

Answer Source

Here you go:

$ftp = ftp_connect($host,$port,$timeout);

$ret = ftp_nb_put($ftp, $dest_file, $source_file, FTP_BINARY, FTP_AUTORESUME);

while (FTP_MOREDATA == $ret)
        // display progress bar, or someting
        $ret = ftp_nb_continue($ftp);

// all done :-)

Error handling omitted for brevity.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download