You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
877 B

8 years ago
  1. <?php
  2. /*
  3. Uploadify
  4. Copyright (c) 2012 Reactive Apps, Ronnie Garcia
  5. Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
  6. */
  7. // Define a destination
  8. $targetFolder = '/uploads'; // Relative to the root
  9. $verifyToken = md5('unique_salt' . $_POST['timestamp']);
  10. if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
  11. $tempFile = $_FILES['Filedata']['tmp_name'];
  12. $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
  13. $targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
  14. // Validate the file type
  15. $fileTypes = array('jpg','jpeg','gif','png'); // File extensions
  16. $fileParts = pathinfo($_FILES['Filedata']['name']);
  17. if (in_array($fileParts['extension'],$fileTypes)) {
  18. move_uploaded_file($tempFile,$targetFile);
  19. echo '1';
  20. } else {
  21. echo 'Invalid file type.';
  22. }
  23. }
  24. ?>