Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $target_dir = "uploads";
- if(!is_dir($target_dir)){
- mkdir($target_dir, 0777, true);
- }
- $FormInputs = array("form1","form2","form4","form4");
- if(isset($_POST["form-action"]) && $_POST["form-action"] == "submit-form") { // check to see if the form was submitted
- foreach($FormInputs as $FormInput){ // loop through form input array
- if(isset($_FILES[$FormInput]['name']) && $_FILES[$FormInput]['name'] != ""){ // check to see if input was submitted with a value
- $target_file = $target_dir . "\". basename($_FILES[$FormInput]['name']); // define the target_file
- $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
- // Check if image file is a actual image or fake image
- $check = getimagesize($_FILES[$FormInput]["tmp_name"]);
- if($check !== false) {
- echo "File is an image - " . $check["mime"] . ".";
- $uploadOk = 1;
- } else {
- echo "File is not an image.";
- $uploadOk = 0;
- }
- }
- }
- }
- ?>
- <form action="Test.php" method="post" enctype="multipart/form-data">
- <?php foreach($FormInputs as $FormInput){?>
- <input type="file" name="$FormInput" size="50" maxlength="25"> <br>
- <?php }?>
- <input type="hidden" name="form-action" value="submit-form"/>
- <input type="submit" name="upload" value="Upload">
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement