1
我需要在使用php cURL下載後重命名文件。使用php cURL移動ftp站點上的文件
這是我有:
$localFile = fopen($fileName, 'w');
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FILE, $localFile);
curl_setopt($curl, CURLOPT_USERPWD, "$ftpUsername:$ftpPassword");
curl_setopt($curl, CURLOPT_POSTQUOTE, array("RNFR $remoteFile", "RNTO $remoteFile.downloaded"));
curl_exec($curl) === false) {
throw new Exception(curl_error($curl));
}
如果我刪除CURLOPT_POSTQUOTE一部分,該文件下載的罰款。我也試過postquote陣列的幾個不同的組合:
curl_setopt($curl, CURLOPT_POSTQUOTE, array("RNFR $remoteFile RNTO $remoteFile.downloaded"));
curl_setopt($curl, CURLOPT_POSTQUOTE, array("-RNFR $remoteFile", "-RNTO $remoteFile.downloaded"));
curl_setopt($curl, CURLOPT_POSTQUOTE, array("-RNFR $remoteFile -RNTO $remoteFile.downloaded"));
curl_setopt($curl, CURLOPT_POSTQUOTE, array("rename $remoteFile $remoteFile.downloaded"));
我已經得到的樣子錯誤:
ERROR : QUOT string not accepted: -RNFR $remoteFile -RNTO $remoteFile.downloaded
最後,添加到「CURLOPT_POSTQUOTE」列表中的** two **命令是:'RNFR remote_file.txt'和'RNTO remote_file_downloaded.txt'。 – cesargastonec 2015-03-06 18:41:54