N
N
nachaloseo2019-01-29 11:34:31
PHP
nachaloseo, 2019-01-29 11:34:31

Uploading multiple files from FTP using PHP?

Good afternoon. I'm trying to set up a PHP script that will download a file to my server every day.
In general, the task is to download 5 files at once. But even so. Help set up.
Files creates but they are empty.

<?php
// путь к удаленному файлу
$remote_file = 'ftp_prices0_1.csv';
$local_file = '1.csv';

// открываем файл для записи
$handle = fopen($local_file, 'w');

$ftp_server = "ftp://***8";
$ftp_user = "***";
$ftp_pass = "***";

// установка соединения
$conn_id = ftp_connect($ftp_server);

// вход с именем пользователя и паролем
$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);

// пытаемся скачать файл и сохранить его в $handle
if (ftp_fget($conn_id, $handle, $remote_file, FTP_ASCII, 0)) {
 echo "Произведена запись в $local_file\n";
} else {
 echo "При скачке $remote_file в $local_file произошла проблема\n";
}

// закрытие соединения и локального файла
ftp_close($conn_id);
fclose($handle);
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Dart, 2019-01-29
@gobananas

I think you need
Either CURL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question