I am trying to transfer a file from one server to another. I am using php5 with curl
$fp = fopen("/tmp/help.txt", "r");
$url = "ftp://admin:support@portal-test.uk.xxx.com:21/tmp/help.txt";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILE, $fp);
//curl_setopt($ch, CURLOPT_FTPASCII, 1);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize(__FILE__));
$result = curl_exec($ch);
print_r(curl_getinfo($ch));
echo "\n\ncURL error number:" .curl_errno($ch);
echo "\n\ncURL error:" . curl_error($ch);
curl_close($ch);
I get an error as below:
Array
(
[url] => ftp://admin:support@portal-test.uk.xxx.com:21/tmp/help.txt
[content_type] =>
[http_code] => 550
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.033012
[namelookup_time] => 0.015422
[connect_time] => 0.015798
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 0
[redirect_time] => 0
)
cURL error number:9
cURL error:Server denied you to change to the given directory
I want to transfer a file from /tmp/ to another server /tmp/. How would i do this?
here is my script which works