Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <?php
  2. $target_dir = "uploads";
  3. if(!is_dir($target_dir)){
  4. mkdir($target_dir, 0777, true);
  5. }
  6.  
  7. $FormInputs = array("form1","form2","form4","form4");
  8.  
  9. if(isset($_POST["form-action"]) && $_POST["form-action"] == "submit-form") { // check to see if the form was submitted
  10.  
  11. foreach($FormInputs as $FormInput){ // loop through form input array
  12. if(isset($_FILES[$FormInput]['name']) && $_FILES[$FormInput]['name'] != ""){ // check to see if input was submitted with a value
  13. $target_file = $target_dir . "\". basename($_FILES[$FormInput]['name']); // define the target_file
  14. $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
  15.  
  16. // Check if image file is a actual image or fake image
  17. $check = getimagesize($_FILES[$FormInput]["tmp_name"]);
  18. if($check !== false) {
  19. echo "File is an image - " . $check["mime"] . ".";
  20. $uploadOk = 1;
  21. } else {
  22. echo "File is not an image.";
  23. $uploadOk = 0;
  24. }
  25. }
  26. }
  27. }
  28. ?>
  29.  
  30. <form action="Test.php" method="post" enctype="multipart/form-data">
  31. <?php foreach($FormInputs as $FormInput){?>
  32. <input type="file" name="$FormInput" size="50" maxlength="25"> <br>
  33. <?php }?>
  34.  
  35. <input type="hidden" name="form-action" value="submit-form"/>
  36. <input type="submit" name="upload" value="Upload">
  37. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement