Curl-FTP-with-php
Download, upload file to ftp with php without timeout, file large, curl ftp download file, upload file to ftp, list file from ftp with curl,
With Magento project
Copy file and folder to project
goto shell and run cmd
1: Xampp --> Shell commander
2: order --> Run command line with what you know.
php -f ftp_download.php --host "ftp.yourhost.com" --user "ussername" --pw "password" --sr "/" --dest "/"
More option Usage:
php ftp_download.php -- [options]
--host Ftp host (required)
--port Ftp Port (Default 21)
--user Ftp Username (default anonymous)
--pwd Ftp Password. (default empty)
--ssl Default false (true/false)
--fm Default FTP_BINARY
--timeout Default 60
--upload Upload all file from src to dest. Default false
--src Download from folder. (required)
--dest Folder save to. (required)
help This help
With order project php Use class Mage_Dataflow_Model_Convert_Adapter_Extend_Curl;
$connect = array(
'host' => $host,
'port' => $port,
'user' => $user,
'password' => $password,
'ssl' => $ssl, // default false
'file_mode' => $filemode, // default FTP_BINARY
'timeout' => $timeout,
);
if($sourceFolder && $destFolder){
$CurlFtp = new Mage_Dataflow_Model_Convert_Adapter_Extend_Curl($connect);
$lsDir = $CurlFtp->getListDir($sourceFolder);
if(!is_dir($destFolder)){
mkdir($dest,'0777',true);
}
if(isset($lsDir['file'])){
$i = 0;
foreach($lsDir['file'] as $key => $file){
if($i == 4) break;
echo "Downloading: $file \r\n";
if($this->_getFtp()->curlGetFile($sourceFolder.DS.$file,$destFolder.'/'.$file, false)){
echo "Download successful File: $file \r\n";
}
}
}else{
echo "Doesn't exists any file in folder";
}
}