PageRenderTime 45ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/test/unit_tests/include/AMP/System/UploadPage.php

https://github.com/radicaldesigns/amp
PHP | 47 lines | 40 code | 6 blank | 1 comment | 5 complexity | c5797d5dc7eafa0edf283dad9f5b035c MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, BSD-3-Clause, LGPL-2.0, CC-BY-SA-3.0, AGPL-1.0
  1. <?php
  2. if ($_SERVER['SERVER_ADDR'] != $_SERVER['REMOTE_ADDR']) {
  3. print "Use of this script is only permitted when testing locally.";
  4. return;
  5. }
  6. if (array_key_exists('userfile', $_FILES)) {
  7. define( 'AMP_LOCAL_PATH', dirname(__FILE__) .'/files' );
  8. define( 'AMP_CONTENT_URL_DOCUMENTS', '/');
  9. define( 'AMP_BASE_INCLUDE_PATH', $_SERVER['DOCUMENT_ROOT'].'/include/' );
  10. define( 'AMP_SYSTEM_FILE_S3_KEY', false );
  11. define( 'AMP_CACHE_TOKEN_LOOKUP', '__LOOKUP__' );
  12. define( 'AMP_SYSTEM_CACHE', 'file');
  13. define( 'AMP_SYSTEM_CACHE_PATH', AMP_LOCAL_PATH . DIRECTORY_SEPARATOR . 'cache');
  14. //print "<pre>". print_r($_FILES, 1) ."</pre>";
  15. include('utility.functions.inc.php');
  16. include('AMP/System/Upload.inc.php');
  17. $upload = &new AMPSystem_Upload($_FILES['userfile']['name']);
  18. $upload->setFolder($_POST['uploadPath']);
  19. $upload->execute($_FILES['userfile']['tmp_name']);
  20. $errors = $upload->getErrors();
  21. if ($errors) {
  22. foreach ($errors as $error) {
  23. print "$error\n<br />";
  24. }
  25. } else {
  26. print 'File uploaded to: '. $upload->getTargetPath() ."\n<br />";
  27. }
  28. exit;
  29. }
  30. ?>
  31. <html>
  32. <body>
  33. <!-- The data encoding type, enctype, MUST be specified as below -->
  34. <form enctype="multipart/form-data" method="POST">
  35. <!-- Name of input element determines name in $_FILES array -->
  36. <input name="uploadPath" type="text" />
  37. <input name="userfile" type="file" />
  38. <input type="submit" value="Send File" />
  39. </form>
  40. </body>
  41. </html>