uploadify.php 748 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /*
  3. Uploadify v3.1.0
  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. if (!empty($_FILES)) {
  10. $tempFile = $_FILES['Filedata']['tmp_name'];
  11. $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
  12. $targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
  13. // Validate the file type
  14. $fileTypes = array('jpg','jpeg','gif','png'); // File extensions
  15. $fileParts = pathinfo($_FILES['Filedata']['name']);
  16. if (in_array($fileParts['extension'],$fileTypes)) {
  17. move_uploaded_file($tempFile,$targetFile);
  18. echo '1';
  19. } else {
  20. echo 'Invalid file type.';
  21. }
  22. }
  23. ?>