Hi guys, following code will transfer files into local filesystem of Webserver. It is also possible,tranfering this file to another ftp-server. What about transfering files(s) to another Webserver. Is there any possibility transfering files to another webserver. Actually,I will get error:
fopen(http://tklustig.ddns.net:1025/img/woman_2.jpg):
failed to open stream: HTTP wrapper does not support writeable connections
That’s way, I upload files to another ftp-server.I am not using any ftp-extension by now
$server="";
$ftp_user_name="";
$ftp_user_pass="";
$dest="";
$source="";
$mode="FTP_ASCII";
$connection = ftp_connect($server);
$login = ftp_login($connection, $ftp_user_name, $ftp_user_pass);
if (!$connection || !$login) { die('Connection attempt failed!'); }
$upload = ftp_put($connection, $dest, $source, $mode);
if (!$upload) { echo 'FTP upload failed!'; }
ftp_close($connection);
Here is code, which 'causes error:
if ($model->loadAll(Yii::$app->request->post()) && $model_eingang->loadAll(Yii::$app->request->post()))
$model->attachement = UploadedFile::getInstances($model, 'attachement');
$bez = "E-Mail-Anhang";
$bez_error = "kein Fehler aufgeteten"
$anhangszaehler = 0;
$anhang = array();
if ($model->upload()) {
$folder_read = Yii::getAlias('@uploading/');[
$folder_write = Yii::getAlias('@emailanhang');
$upload_copy = opendir($folder_read);
while ($file = readdir($upload_copy)) {
if ($file != "." && $file != ".." && $file != ".gitkeep" && $file != ".gitignore") {
copy($folder_read . $file, $folder_write . $file);
$folder_http = "http://tklustig.ddns.net:1025/img/";
fopen($folder_http.$file,"w"); //this will cause error
copy($folder_read . $file, $folder_http . $file);//this will cause error as well
$anhang[$anhangszaehler] = $file;
$anhangszaehler++;
}
}
.
.
.