ftp_fget_basic.phpt 916 B

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