Answer the question
In order to leave comments, you need to log in
How to display the number of files in a specific folder on another server via FTP, on the site screen?
How to display the number of files in a certain folder on another server via FTP on the site screen?
Answer the question
In order to leave comments, you need to log in
$ftp = ftp_connect('ftp.example.com');
ftp_login($ftp, 'username', 'password');
$files = ftp_nlist($ftp, '/path/to/dir');
var_dump(count($files));
ftp_close($ftp);
ajax+php
Through ajax make a request, through php connect via ftp.
Code example:
$ftp_login= "ftp_login";
$ftp_pass= "ftp_pass";
//Коннектимся к ftp, получаем список файлов
$conn_id = ftp_connect ( "domain.site.com" );
$login_result = ftp_login ( $conn_id, $ftp_login, $ftp_pass );
//Провеяем $login_result
//Заходим внутрь нужной папки. Типа комманда "cd"
if ( !ftp_chdir($conn_id, "www")) {
echo "Couldn't change directory";
die;
}
//Получаем список файлов и папок "там"
$ftp_nlist= ftp_nlist( $conn_id, "." );
foreach ($ftp_nlist as $v) {
//$v — название файла, папки. Делаем что-нибудь с ним
//Например, копируем к себе: ftp_get
//Например, удаляем на фтп: ftp_delete
} //end foreach
ftp_close($conn_id);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question