ftp_fget_basic.phpt 943 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --TEST--
  2. FTP ftp_fget file for both binary and ASCII transfer modes
  3. --CREDITS--
  4. Nathaniel McHugh
  5. --SKIPIF--
  6. <?php
  7. require 'skipif.inc';
  8. ?>
  9. --FILE--
  10. <?php
  11. require 'server.inc';
  12. $ftp = ftp_connect('127.0.0.1', $port);
  13. if (!$ftp) die("Couldn't connect to the server");
  14. var_dump(ftp_login($ftp, 'user', 'pass'));
  15. //test simple text transfer
  16. $fp = tmpfile();
  17. var_dump(ftp_fget($ftp, $fp ,'a story.txt', FTP_ASCII));
  18. fseek($fp, 0);
  19. echo fgets($fp);
  20. $postition = ftell($fp);
  21. //test binary data transfer
  22. var_dump(ftp_fget($ftp, $fp, 'binary data.bin', FTP_BINARY));
  23. fseek($fp, $postition);
  24. var_dump(urlencode(fgets($fp)));
  25. //test non-existent file request
  26. ftp_fget($ftp, $fp ,'a warning.txt', FTP_ASCII);
  27. //remove file
  28. fclose($fp);
  29. ?>
  30. --EXPECTF--
  31. bool(true)
  32. bool(true)
  33. For sale: baby shoes, never worn.
  34. bool(true)
  35. string(21) "BINARYFoo%00Bar%0D%0A"
  36. Warning: ftp_fget(): a warning: No such file or directory in %sftp_fget_basic.php on line %d