/test/unit_tests/include/AMP/System/UploadPage.php
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
- <?php
- if ($_SERVER['SERVER_ADDR'] != $_SERVER['REMOTE_ADDR']) {
- print "Use of this script is only permitted when testing locally.";
- return;
- }
- if (array_key_exists('userfile', $_FILES)) {
- define( 'AMP_LOCAL_PATH', dirname(__FILE__) .'/files' );
- define( 'AMP_CONTENT_URL_DOCUMENTS', '/');
- define( 'AMP_BASE_INCLUDE_PATH', $_SERVER['DOCUMENT_ROOT'].'/include/' );
- define( 'AMP_SYSTEM_FILE_S3_KEY', false );
- define( 'AMP_CACHE_TOKEN_LOOKUP', '__LOOKUP__' );
- define( 'AMP_SYSTEM_CACHE', 'file');
- define( 'AMP_SYSTEM_CACHE_PATH', AMP_LOCAL_PATH . DIRECTORY_SEPARATOR . 'cache');
- //print "<pre>". print_r($_FILES, 1) ."</pre>";
- include('utility.functions.inc.php');
- include('AMP/System/Upload.inc.php');
- $upload = &new AMPSystem_Upload($_FILES['userfile']['name']);
- $upload->setFolder($_POST['uploadPath']);
- $upload->execute($_FILES['userfile']['tmp_name']);
- $errors = $upload->getErrors();
- if ($errors) {
- foreach ($errors as $error) {
- print "$error\n<br />";
- }
- } else {
- print 'File uploaded to: '. $upload->getTargetPath() ."\n<br />";
- }
- exit;
- }
- ?>
- <html>
- <body>
- <!-- The data encoding type, enctype, MUST be specified as below -->
- <form enctype="multipart/form-data" method="POST">
- <!-- Name of input element determines name in $_FILES array -->
- <input name="uploadPath" type="text" />
- <input name="userfile" type="file" />
- <input type="submit" value="Send File" />
- </form>
- </body>
- </html>