Guest User

Untitled

a guest
Jul 17th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <?php
  2. $myFile = "log.txt";
  3. $target_path = "images/".$_POST['folder']."/";
  4. $target_path2 = $target_path . basename( $_FILES['uploadedfile']['name']);
  5. //var_dump(file_exists($_FILES['uploadfieldname']['tmp_name']));
  6. if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path2)) {
  7.  
  8. $dir = opendir($target_path);
  9. $x = 1;
  10. $extension = substr($_FILES['uploadedfile']['name'], -4);
  11. while(($file = readdir($dir)) !== false)
  12. //echo $target_path2;
  13. {
  14. if(is_file($target_path2))
  15. {
  16. $filex = intval(substr($file, 0, strlen($file)-4));
  17. //echo $filex;
  18. if($filex >= $x)
  19. {
  20. $x = $filex + 1;
  21. //echo $x;
  22. }
  23. }
  24.  
  25. }
  26. rename($target_path2, $target_path.$x.$extension);
  27. /* echo "The file ". basename($_FILES['uploadedfile']['name']).
  28. " has been uploaded"; */
  29. $fh = fopen($myFile, 'w');
  30. fwrite($fh, "The file ". basename($_FILES['uploadedfile']['name']).
  31. " has been uploaded to: ". $targetpath);
  32. fclose($fh);
  33. header("Location: /wherewillienduptoday/");
  34. } else{
  35. echo "There was an error uploading the file, please try again!";
  36. }
  37. ?>
Add Comment
Please, Sign In to add comment