You can get that information plus a lot more (maybe more than you want 🙂 ) with curl:
define('ASCII', true);
define('BINARY', false);
$server = 'ftp://ftp.example.com';
$username = 'username';
$password = 'password';
$local_path = '/local/path/';
$remote_path = '/remote/path/';
$local_file = 'local_file.tar';
$remote_file = 'remote_file.tar';
$trans_mode = BINARY;
$fp = fopen($file_path . $up_file, 'r');
$ch = curl_init();
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($local_path . $local_file));
curl_setopt($ch, CURLOPT_URL, $server . $remote_path . $remote_file);
curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_UPLOAD, true);
curl_setopt($ch, CURLOPT_TRANSFERTEXT, $trans_mode);
curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'curl_header_read');
$curl = curl_exec($ch);
$curl_info = curl_getinfo($ch);
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
curl_close($ch);
fclose($fp);
$tab = ' ';
echo '<br /><b>curl_exec()</b> = ' . $curl . '<br />';
echo '<br /><b>curl_errno()</b> = ' . $curl_errno . '<br />';
If ($curl_error != '') {
echo '<br /><b>curl_error()</b> = ' . $curl_error . '<br />';
}
echo '<br /><b>curl_getinfo()</b> =<br />';
foreach ($curl_info as $key => $value) {
echo $tab . $key . ' => ' . $value;
echo '<br />';
}
function curl_header_read($ch, &$str) {
echo '<i>Server:</i> ' . nl2br($str);
$len = strlen($str);
return $len;
}