I am trying to make a multiple file upload page using a single input. But when I upload it show this message
Undefined index: files in C:\xampp\htdocs\tapromtour.com\admin_panel\view\gallery_script.php on line 13
This is my upload form code:
<form action="gallery_script" method="POST" enctype="multipart/form-data" style="width:950px;text-align:center;">
 <br/><br/>
<input name="title" type="text" placeholder="Give the album name" style="padding:5px; width:500px;" required ="required"/><br/><br/>
 <input type="file" name="attachPhoto1[]" multiple="multiple" required="required"/>
 <br/><br/>
 <input type="submit" name="submit" value="Submit" id="submit" />
</form>
And this is my upload php page:
<?php
if (isset($_POST['submit'])){
    //file uplaod
   $title = $_POST['title'];
   if(!empty($_FILES["attachPhoto1"]['name'])) {
        $allowedExts = array("gif", "jpeg", "jpg", "png");
        $error_uploads = 0;
        $total_uploads = array();
        $upload_path = '../album/';
        foreach($_FILES["attachPhoto1"]['name'] as $key => $value) {
            $temp = explode(".", $_FILES["attachPhoto1"]['name'][$key]);
            $extension = end($temp);
            if ($_FILES["files"]["type"][$key] != "image/gif"
                && $_FILES["files"]["type"][$key] != "image/jpeg"
                && $_FILES["files"]["type"][$key] != "image/jpg"
                && $_FILES["files"]["type"][$key] != "image/pjpeg"
                && $_FILES["files"]["type"][$key] != "image/x-png"
                && $_FILES["files"]["type"][$key] != "image/png"
                && !in_array($extension, $allowedExts)) {
                $error_uploads++;
                continue;
            }
            $file_name = time().rand(1,5).rand(6,10).'_'.str_replace(' ', '_', $_FILES["attachPhoto1"]['name'][$key]);
            if(move_uploaded_file($_FILES["attachPhoto1"]['tmp_name'][$key], $upload_path.$file_name)) {
                $total_uploads[] = $file_name;
                mysql_query ("INSERT INTO gallery (id, image, title, date) VALUE ('','$file_name','$title',now())");
                header("Location: gallery");
            } else {
                $error_uploads++;
            }
        }
        if(sizeof($total_uploads)) {
        }
        }
    }    
//file uplaod
?>
I don't know what is wrong in the above code. It looks fine but it shows the message when I upload the images. Can you tell me what wrong with the above code? Thanks for helping.
