Guest User

Untitled

a guest
Apr 25th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <?php
  2. require 'common.php';
  3.  
  4. Spec::it('should be able to upload => test_1');
  5. function test_1() {
  6. if (!empty($_FILES) && isset($_FILES['file']['tmp_name'])) {
  7. if (move_uploaded_file($_FILES['file']['tmp_name'], dirname(__FILE__).DS.'uploaded_file')) {
  8. return SUCCESS;
  9. }
  10. }
  11. }
  12.  
  13. Spec::it('Should be able to rename upload file => test_2');
  14. function test_2() {
  15. $file = dirname(__FILE__).DS.'uploaded_file';
  16. $newname = dirname(__FILE__).DS.'new_file';
  17.  
  18. if (rename($file, $newname)) {
  19. return SUCCESS;
  20. }
  21. }
  22.  
  23. Spec::it('Should be able to remove a file after renamed => test_3');
  24. function test_3() {
  25. $file = dirname(__FILE__).DS.'new_file';
  26.  
  27. if (unlink($file))
  28. return SUCCESS;
  29. }
  30.  
  31. Spec::it("is not quite sure => test_4");
  32. function test_4() {
  33. return UNSURE;
  34. }
  35.  
  36. Spec::run();
  37. ?>
  38. <form method="post" enctype="multipart/form-data">
  39. <input type="file" name="file">
  40. <input type="submit>
  41. </form>
Add Comment
Please, Sign In to add comment