選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

uploadify.php 837 B

4年前
1234567891011121314151617181920212223242526272829
  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. ?>