Skip to content

Instantly share code, notes, and snippets.

@AbhishekGhosh
Created December 20, 2015 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbhishekGhosh/0c3307f20f37d2eb365e to your computer and use it in GitHub Desktop.
Save AbhishekGhosh/0c3307f20f37d2eb365e to your computer and use it in GitHub Desktop.
PHP FTP Connection Check
<?php
$conn = ftp_connect("127.0.0.1");
ftp_login($conn, "username_here", "password_here");
ftp_pasv($conn, true);
ftp_chdir($conn, "/etc");
$files = ftp_nlist($conn, ".");
srand ((float)microtime()*1000000);
shuffle($files);
$filetoget = array_pop($files);
ftp_get($conn, $filetoget, $filetoget, FTP_BINARY);
ftp_close($conn);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment