开发者

ftp upload not working

File is not uploading to FTP and errors: Warning: ftp_put() [function.ftp-put]开发者_开发问答: Can't open that file: No such file or directory coming. We are using following code:

    $server = 'ftp.domain.com';
$ftp_user_name = 'upload@domain.com';
$ftp_user_pass = 'password';
$dest = 'files/test.txt';
$source = 'test.txt';
$src = ini_get("upload_tmp_dir");

$connection = ftp_connect($server);
$login = ftp_login($connection, $ftp_user_name, $ftp_user_pass);
if (!$connection || !$login) { die('Connection attempt failed!'); }
$upload = ftp_put($connection, $dest, $source, FTP_BINARY);
if (!$upload) { echo 'FTP upload failed!'; }
ftp_close($connection); 


Here's an answer from the comments of php.net on ftp_put:


Found the prob, you can't put a path to the destination file (even though I can do that in the dos ftp client...?)

e.g. - this doesn't work

ftp_put($conn, '/www/site/file.html','c:/wamp/www/site/file.html',FTP_BINARY);

you have to put

ftp_chdir($conn, '/www/site/');
ftp_put($conn,'file.html', 'c:/wamp/www/site/file.html', FTP_BINARY );

http://php.net/manual/en/function.ftp-put.php


I had same problem and I solved it using ftp_nb_put(). Same function but it allows your program to run more connections or something:-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜