Guest User

Untitled

a guest
Oct 23rd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <?php
  2.  
  3. if (isset($_POST['submit'])) {
  4.  
  5. $file = $_FILES['file'];
  6. //print_r($file);
  7.  
  8. $fileName = $_FILES['file']['name'];
  9. $fileTmpName = $_FILES['file']['tmp_name'];
  10. $fileType = $_FILES['file']['type'];
  11. $fileSize = $_FILES['file']['size'];
  12. $fileError = $_FILES['file']['error'];
  13.  
  14. $fileExt = explode('.', $fileName);
  15. $fileActualExt = strtolower(end($fileExt));
  16.  
  17. $allowed = array("jpg", "jpeg", "png");
  18.  
  19. if (in_array($fileActualExt, $allowed)) {
  20.  
  21. if ($fileError == 0) {
  22.  
  23. if ($fileSize < 1000000) {
  24.  
  25. $fileNameNew = uniqid('', true).".".$fileActualExt;
  26. $fileDestination = "/opt/lampp/htdocs/matrimony/upload/".$fileNameNew;
  27.  
  28. if (move_uploaded_file($fileTmpName, $fileDestination)) {
  29.  
  30. header("Location:img.php?success");
  31.  
  32. } else {
  33.  
  34. echo "something wrong";
  35. }
  36.  
  37.  
  38. } else {
  39.  
  40. echo "your file is too big!";
  41.  
  42. }
  43.  
  44. } else {
  45.  
  46. echo "There was error in uploading your file!";
  47. }
  48.  
  49. } else {
  50.  
  51. echo "you cannot upload this type of files!";
  52. }
  53. }
  54.  
  55. ?>
Add Comment
Please, Sign In to add comment