07-02-2018, 07:13 AM
Hi Guys,
I wrote a php file to transfer a CSV regularly to another server. Unfortunately, nothing is transmitted. Does anyone have an idea what is wrong?
In response comes:
I wrote a php file to transfer a CSV regularly to another server. Unfortunately, nothing is transmitted. Does anyone have an idea what is wrong?
PHP Code:
<?
set_time_limit(999);
/***
nun FTP Upload mit curl
***/
function curlUpload($ftp,$ftpFile) {
$fp = fopen($ftpFile, "r");
$url = "ftp://".$ftp['user'].":".$ftp['passwd']."@".
$ftp['host'].":21" .$ftp['pfad'].$ftp['file'];
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($handle, CURLOPT_UPLOAD, 1);
curl_setopt($handle, CURLOPT_INFILE, $fp);
curl_setopt($handle, CURLOPT_INFILESIZE, filesize($ftpFile));
curl_setopt($handle, CURLOPT_TIMEOUT, 900);
curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 900);
$result = curl_exec($handle);
$info = curl_getinfo ($handle);
curl_close($handle);
return $info;
}
$ftp['user'] = '1000732382';
$ftp['passwd'] = 'x1h0cJl5';
$ftp['host'] = 'ftp.test.at';
$ftp['pfad'] = '/Schnittstelle_TEST/';
$ftp['file'] = "text.csv";
$ftpFile = "text.csv";
$info = curlUpload($ftp,$ftpFile);
print_r($info);
?>
In response comes:
PHP Code:
Array ( [url] => ftp://test@ftp.test..de:21/text.csv [content_type] => [http_code] => 421 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.065181 [namelookup_time] => 0.004295 [connect_time] => 0.022713 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 [redirect_url] => [primary_ip] => 0.0.0.0 [certinfo] => Array ( ) [primary_port] => 21 [local_ip] => 0.0.0.0 [local_port] => 52838 )