Hi guys,
following method of my FTP class will throw out following Exception
yii\base\ErrorException: ftp_put(): Using BINARY mode to transfer data. in
D:\xampp\htdocs\yii2_perswitch\common\wsl_components\FTPZugang.php:105
Here is method which will 'cause this error
public function DateienHochloaden($render = NULL, $connection, $localFile, $LocalDirectory) {
$session = new Session();
$txt = '/txt/';
try {
$basis = $this->GetZugangsDaten($render);
$SourceDirectory = $basis[4];
if (preg_match($txt, $localFile))
$mode = FTP_ASCII;
else
$mode = FTP_BINARY;
try {
$putFile = $connection->put($SourceDirectory . $localFile, $LocalDirectory . $localFile, $mode);
} catch (\Exception $e) {
$SwitchFTP = $this->FTPPassivModus();
if ($SwitchFTP[0]) {
//This will throw out Exception. So, this is line 105!
$putFile = ftp_put($SwitchFTP[1], $SourceDirectory . $localFile, $LocalDirectory . $localFile,$mode);
$session->addFlash('info', 'Der Upload erfolgte im Passivmodus. Das deutet auf Probleme mit Ihrer Netzwerkkonfiguration hin. Informieren Sie Ihren Admin<br><br> Einzelheiten hier:' . $e);
} else {
$putFile = false;
}
}
This will show var_dump:
var_dump($SwitchFTP[1]);
var_dump($SourceDirectory.$localFile);
var_dump($LocalDirectory.$localFile);
var_dump($mode);
// will show this::
resource(191) of type (FTP Buffer)
string(20) "/Uploads/ man_2.jpg"
string(63) "D:\xampp\htdocs\yii2_perswitch\frontend/uploadedfiles/man_2.jpg"
int(2)
As it seems, ft_put is wrong implemented. I have absolutely no idea, why!?
I used to implement this code according to php manuals. Nevertheless, I will get upper Exception
Any ideas, what I do wrong?