add FTP Upload
This commit is contained in:
parent
30b675e999
commit
a05da31f8f
1434
jtl/cds-export.csv
1434
jtl/cds-export.csv
File diff suppressed because it is too large
Load Diff
@ -78,24 +78,25 @@ class Ftp
|
||||
*/
|
||||
public function uploadFile(string $localFile): bool
|
||||
{
|
||||
#dd(array($localFile,$this->getHost(),$this->getUser(), $this->getPassword(),$this->getRemoteDir()));
|
||||
$sftp = new SFTP($this->getHost(),$this->getPort());
|
||||
$sftp_login = $sftp->login($this->getUser(), $this->getPassword());
|
||||
//dump(array('$sftp_login'=>$sftp_login,'Line'=>__LINE__,'Method'=>__METHOD__));
|
||||
$remoteFile = 'order_'.date('YmdHis').'.csv';
|
||||
if($sftp_login){
|
||||
$r = $sftp->put($this->getRemoteDir().$remoteFile.'.tmp', $localFile, SFTP::SOURCE_LOCAL_FILE);
|
||||
//dump(array('$r'=>$r,$this->getRemoteDir().$remoteFile, $localFile,'Line'=>__LINE__));
|
||||
$ftp = ftp_ssl_connect($this->getHost(),$this->getPort());
|
||||
$ftp_login = ftp_login($ftp,$this->getUser(), $this->getPassword());
|
||||
ftp_pasv($ftp, true);
|
||||
|
||||
$remoteFile = 'stock_'.date('YmdHis').'.csv';
|
||||
|
||||
if($ftp_login){
|
||||
$r = ftp_put($ftp,$this->getRemoteDir().$remoteFile, $localFile);
|
||||
ftp_close($ftp);
|
||||
// dump(array('$r'=>$r,$this->getRemoteDir().$remoteFile, $localFile,'Line'=>__LINE__));
|
||||
if($r){
|
||||
if($sftp->rename($this->getRemoteDir().$remoteFile.'.tmp',$this->getRemoteDir().$remoteFile))
|
||||
// if(ftp_rename($ftp,$this->getRemoteDir().$remoteFile.'.tmp',$this->getRemoteDir().$remoteFile)){
|
||||
// ftp_close($ftp);
|
||||
return unlink($localFile); # löschen der datei
|
||||
else
|
||||
return false;
|
||||
//}
|
||||
}else
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
@ -127,17 +127,17 @@ class HiltesImport
|
||||
$c = 0;
|
||||
while (!$file->eof()) {
|
||||
|
||||
#*** Convertiert die Zeile in UTF8
|
||||
$data = iconv('ISO-8859-1','UTF-8',$file->fgets());
|
||||
|
||||
#*** Überspringt die erste Zeile
|
||||
if($c == 0){
|
||||
$c++;
|
||||
continue;
|
||||
}
|
||||
// #*** Convertiert die Zeile in UTF8
|
||||
// $data = iconv('ISO-8859-1','UTF-8',$file->fgets());
|
||||
//
|
||||
// #*** Überspringt die erste Zeile
|
||||
// if($c == 0){
|
||||
// $c++;
|
||||
// continue;
|
||||
// }
|
||||
|
||||
#*** Speichert die Zeile
|
||||
$this->switchSaveData($this->splitLine($data));
|
||||
$this->switchSaveData($this->splitLine($file->fgets()));
|
||||
$c++;
|
||||
|
||||
}
|
||||
|
@ -87,7 +87,14 @@ class Jtl
|
||||
{
|
||||
try {
|
||||
$writer = Writer::createFromPath(getcwd().'/jtl/cds-export.csv', 'w+');
|
||||
$writer->insertAll(new \ArrayIterator($data));
|
||||
$bytes = $writer->insertAll(new \ArrayIterator($data));
|
||||
|
||||
if($bytes){
|
||||
$this->logger->info('Exported '.$bytes.' bytes');
|
||||
|
||||
$FTP = new Ftp();
|
||||
$FTP->uploadFile(getcwd().'/jtl/cds-export.csv');
|
||||
}
|
||||
|
||||
}catch (\Exception $e){
|
||||
$this->logger->error($e->getMessage());
|
||||
@ -95,4 +102,6 @@ class Jtl
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user