upload_file.php 675 B

12345678910111213141516171819202122232425
  1. <?php
  2. // Define a destination
  3. $targetFolder = '/home/admin/'; // Relative to the root
  4. $verifyToken = md5('unique_salt' . $_POST['timestamp']);
  5. if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
  6. $tempFile = $_FILES['Filedata']['tmp_name'];
  7. $targetPath = $targetFolder;
  8. $targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
  9. // Validate the file type
  10. //$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
  11. //$fileParts = pathinfo($_FILES['Filedata']['name']);
  12. //if (in_array($fileParts['extension'],$fileTypes)) {
  13. move_uploaded_file($tempFile,$targetFile);
  14. echo '1';
  15. //} else {
  16. // echo 'Invalid file type.';
  17. // }
  18. }
  19. ?>