1--TEST-- 2FTP ftp_get file for both binary and ASCII transfer modes 3--CREDITS-- 4Nathaniel McHugh 5--SKIPIF-- 6<?php 7require 'skipif.inc'; 8?> 9--FILE-- 10<?php 11require 'server.inc'; 12 13$ftp = ftp_connect('127.0.0.1', $port); 14if (!$ftp) die("Couldn't connect to the server"); 15 16var_dump(ftp_login($ftp, 'user', 'pass')); 17 18//test simple text transfer 19$tmpfname = tempnam(dirname(__FILE__), "ftp_test"); 20var_dump(ftp_get($ftp, $tmpfname ,'a story.txt', FTP_ASCII)); 21echo file_get_contents($tmpfname); 22unlink($tmpfname); 23 24//test binary data transfer 25$tmpfname = tempnam(dirname(__FILE__), "ftp_test"); 26var_dump(ftp_get($ftp, $tmpfname, 'binary data.bin', FTP_BINARY)); 27var_dump(urlencode(file_get_contents($tmpfname))); 28unlink($tmpfname); 29 30//test non-existent file request 31ftp_get($ftp, $tmpfname ,'a warning.txt', FTP_ASCII); 32 33//test invalid ftp_get params 34var_dump(ftp_get('foo', 'bar', 'baz')); 35?> 36--EXPECTF-- 37bool(true) 38bool(true) 39For sale: baby shoes, never worn. 40bool(true) 41string(21) "BINARYFoo%00Bar%0D%0A" 42 43Warning: ftp_get(): a warning: No such file or directory in %sftp_get_basic.php on line %d 44 45Warning: ftp_get() expects parameter 1 to be resource, string given in %s on line %d 46NULL 47