Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <?php
  2.  
  3. if ( count( $argv ) != 3)
  4. {
  5. die( 'arguments are not correct' );
  6. }
  7. else {
  8. $local_file = $argv[1];
  9. $server_file = '/'.$argv[2];
  10. }
  11.  
  12. $ftp_server = ""; // Address of FTP server.
  13. $ftp_user_name = ""; // Username
  14. $ftp_user_pass = ""; // Password
  15.  
  16.  
  17.  
  18. $conn_id = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
  19.  
  20.  
  21.  
  22. $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
  23.  
  24.  
  25. if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
  26. echo "Successfully written to $local_filen";
  27. } else {
  28. echo "There was a problemn";
  29. }
  30.  
  31.  
  32. ftp_close($conn_id);
  33.  
  34. $buffer_size = 4096; // read 4kb at a time
  35. $out_file_name = str_replace('.gz', '', $local_file);
  36.  
  37.  
  38. $file = gzopen($local_file, 'rb');
  39. $out_file = fopen($out_file_name, 'wb');
  40.  
  41.  
  42. while (!gzeof($file)) {
  43. // Read buffer-size bytes
  44. fwrite($out_file, gzread($file, $buffer_size));
  45. }
  46.  
  47.  
  48. fclose($out_file);
  49. gzclose($file);
  50.  
  51.  
  52.  
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement