如何在PHP中使用ftp上传图像?

I tried to upload images to ftp server, but I can't connect to it.

a.html:

<html>
    <body>
        <form method="post" action="b.php" enctype="multipart/form-data">
            <input id="file" name="file" type="file">
            <input value="upload" name="submit" type="submit">
        </form>
    </body>
</html>

and b.php:

<?php
$host = 'ftp.uw.hu';
$usr = 'myname';
$pwd = 'mypass';
$local_file = $_FILES['file'];
$ftp_path = '/a/'.$_FILES['file'].'(2)';
$conn_id = ftp_connect($host) or die ("Cannot connect to host");
ftp_login($conn_id, $usr, $pwd) or die("Cannot login");
$upload = ftp_put($conn_id, $ftp_path, $local_file, FTP_ASCII);
?>

I always get "Cannot connect to host" error message, but I don't know why. I tried another ftp server (ftp.atw.hu) but I got the same error.

http://php.net/manual/en/function.ftp-put.php This may help you!!! Refer it!!!