Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downloading multiple Files #34

Open
PenneiU opened this issue Apr 9, 2015 · 0 comments
Open

Downloading multiple Files #34

PenneiU opened this issue Apr 9, 2015 · 0 comments
Labels
Milestone

Comments

@PenneiU
Copy link

PenneiU commented Apr 9, 2015

Source:

$this->Ftp = new Ftp();
$this->Ftp->useDbConfig = 'ftpServer';
$this->Ftp->connect();
try {
$files = $this->Ftp->find('all', array('conditions' => array('path' => $this->rootFileDirectoryFTP)));
} catch (Exception $e) {
debug($e->getMessage());
}
foreach ($files as $value) {
if ($value['Ftp']['is_dir'] == 0 && $value['Ftp']['is_link'] == 0) {
$remotefile = $value['Ftp']['path'] . $value['Ftp']['filename'];
$localfile = $this->rootFileDirectoryPC . $value['Ftp']['filename'];
$this->out($remotefile);
$this->out($localfile);
try {
if ($this->Ftp->save(array(
'local' => $localfile,
'remote' => $remotefile,
'direction' => 'down',
))) {
$this->out('Success!');
}
} catch (Exception $e) {
$this->out($e->getMessage());
}
}
}

Result:

/var/www/omarbeit/CONTRIBUTING.md
C:\testroot\CONTRIBUTING.md
Failed to download
/var/www/omarbeit/README.md
C:\testroot\README.md
Could not change directory
/var/www/build.properties
C:\testroot\build.properties
Failed to download
/var/www/build.xml
C:\testroot\build.xml
Could not change directory
/var/www/composer.json
C:\testroot\composer.json
Failed to download

System:

PC: Windows 7
FTP: Debian Wheezy

Problem:

If I try to download multiple files from the FTP which I have found by FTP->find(), I am getting once the error "Failed to download" and then once the error "Could not change directory". If I use for example this
$remotefile = $value['Ftp']['path'] . 'composer.json';
$localfile = $this->rootFileDirectoryPC . $value['Ftp']['filename'];
$this->out($remotefile);
$this->out($localfile);
try {
if ($this->Ftp->save(array(
'local' => $localfile,
'remote' => $remotefile,
'direction' => 'down',
))) {
$this->out('Success!');
}
} catch (Exception $e) {
$this->out($e->getMessage());
}

It success

/var/www/composer.json
C:\testroot\composer.json
Success!

@dereuromark dereuromark added this to the 2.x milestone Apr 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants