Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( count( $argv ) != 3)
- {
- die( 'arguments are not correct' );
- }
- else {
- $local_file = $argv[1];
- $server_file = '/'.$argv[2];
- }
- $ftp_server = ""; // Address of FTP server.
- $ftp_user_name = ""; // Username
- $ftp_user_pass = ""; // Password
- $conn_id = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
- $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
- if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
- echo "Successfully written to $local_filen";
- } else {
- echo "There was a problemn";
- }
- ftp_close($conn_id);
- $buffer_size = 4096; // read 4kb at a time
- $out_file_name = str_replace('.gz', '', $local_file);
- $file = gzopen($local_file, 'rb');
- $out_file = fopen($out_file_name, 'wb');
- while (!gzeof($file)) {
- // Read buffer-size bytes
- fwrite($out_file, gzread($file, $buffer_size));
- }
- fclose($out_file);
- gzclose($file);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement