Guest User

Untitled

a guest
Jun 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. if(isset($_FILES["char"])){
  2. if($_FILES["char"]["name"] != ""){
  3. $char = $_FILES["char"]["name"];
  4. $extension = strtolower(getExtension($char));
  5. if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")){
  6. $blnErrors = true;
  7. $errors[] = "Your character screenshot is not a picture file.";
  8. }else{
  9. $size = filesize($_FILES['char']['tmp_name']);
  10.  
  11. $max_upload = (int)(ini_get('upload_max_filesize'));
  12. $max_post = (int)(ini_get('post_max_size'));
  13. $memory_limit = (int)(ini_get('memory_limit'));
  14. $upload_mb = min($max_upload, $max_post, $memory_limit) * 1024 * 1024;
  15.  
  16. if($size > $upload_mb || $size == null){
  17. $blnErrors = true;
  18. $errors[] = "The screenshot you are trying to upload is too big.";
  19. }else{
  20. $copied = copy($_FILES['char']['tmp_name'], "assets/screenshots/character/".$userinfo["username"].".".$extension);
  21. if (!$copied){
  22. $blnErrors = true;
  23. $errors[] = "Something went wrong while uploading your screenshot. Please try again.";
  24. }else{
  25. $userinfo["char_url"] = "assets/screenshots/character/".$userinfo["username"].".".$extension;
  26. }
  27. }
  28. }
  29. }
  30. }
Add Comment
Please, Sign In to add comment