Accès serveur OK"; } else { echo "
Accès serveur en erreur
"; } if (@ssh2_auth_password($authent, SFTP_USER, SFTP_PASS)) { echo "
Authentification OK
"; } else { echo "
Authentification En erreur
"; } if ($connexion = @ssh2_sftp($authent)) { echo "
Connexion OK
"; } else { echo "
Connexion En erreur
"; } $stream = @fopen("ssh2.sftp://" . $connexion . SFTP_REMOTE . "test.txt", "w"); if ($stream == FALSE){ echo "
Impossible d'écrire sur le serveur distant
"; } else { echo "
Succès d'écriture sur le serveur distant
"; } $realpath = @ssh2_sftp_realpath($connexion, SFTP_REMOTE); $dir = "ssh2.sftp://" . $connexion . $realpath; $tempArray = array(); if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { echo $file; $tempFile = NULL; $realpath = @ssh2_sftp_realpath($connexion, $file); $filetype = filetype($dir . $realpath); $size = sprintf("%.2f", filesize($dir . $realpath)); if ($filetype != "dir") { $infos = @ssh2_sftp_stat($connexion, SFTP_REMOTE.$file); $tempFile["file"] = $file; print_r($infos); //$tempFile["size"] = $infos["size"]; // $tempFile["date"] = $infos["atime"]; $tempArray[] = $tempFile; } } closedir($dh); } } print_r($tempArray); } testSFTP();