I am not able to transfer file from one server to another using ftp_put() below is the warning its showing and also files are not getting transfered.
If i put absolute path below error is coming
>Warning: ftp_fput() [function.ftp-fput]: Can't open that file: No such file or directory in ...

Recommended Answers

All 8 Replies

It may be a wrong path to the local file, make sure you use absolute paths:

$file = $_SERVER['DOCUMENT_ROOT'] . '/path/to/file.ext';

Are you using ftp_put or ftp_fput, you mention the first, but the warning shows the second. Their functionality is different.

ftp_fput function using

does the file you are moving exist an have you opened it?
show us some code
or do we have to keep gessing?

$file = 'test2.php';
$fp = fopen($file, 'r');

// set up basic connection
$conn_id = ftp_connect('test.com');
$dest  = "/home/xxxxx/public_html/";
// login with username and password
$login_result = ftp_login($conn_id, 'xxxx', 'xxxx');

// try to upload $file

    echo "Successfully uploaded $file\n";
} else {
    echo "There was a problem while uploading $file\n";
}

// close the connection and the file handler
ftp_close($conn_id);
fclose($fp);

make sure test.php was realy existing

can you echo $fp. let us see if there's content

Your code misses the ftp_fput statment (copy&past error?)
the example code from php.net that you apartly use
works for me
are you using $dest as $file?

$remote_file=$dest.$file;
// try to upload $file
if (ftp_fput($conn_id, $remote_file, $fp, FTP_ASCII)) {
    echo "Successfully uploaded $file\n";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.