I am not very well in PHP. I want to upload two images separately and stored those in two different field in table. My HTML code is as below :
<form method="post" enctype="multipart/form-data" name="News Slider">
                <input name="img" type="file" required id="sortpicture"/>
                <input name="img2" type="file" required id="sortpicture"/>
                <button type="submit" name="submit" value="Save and Submit" class="btn btn-app">Save and Submit</button>
              <button type="reset" name="reset" value="Reset the Form" class="btn btn-app">Reset the Form</button>
              </form>
My table structure is like ImageId | image_name | image_thumbnail
I wrote code as below, but it stores only img2 (second selected image) image in image_name and image_thumbnail field. But img (first selected image) is not storing any where.
if(isset($_REQUEST['submit']))
     {
        if($_FILES['img']['name']!='')
    {
        $tmp_name = $_FILES["img"]["tmp_name"];
        $namefile = $_FILES["img"]["name"];
        $ext = end(explode(".", $namefile));
        $image_name=time().".".$ext;
        $fileUpload = move_uploaded_file($_FILES['img']['tmp_name'],"uploadnewsslider/".$image_name);
    }
    if($_FILES['img2']['name']!='')
    {
        $tmp_name = $_FILES["img2"]["tmp_name"];
        $namefile2 = $_FILES["img2"]["name"];
        $ext = end(explode(".", $namefile2));
        $image_thumbnail=time().".".$ext;
        $fileUpload2 = move_uploaded_file($_FILES['img2']['tmp_name'],"uploadnewsslider/".$image_thumbnail);
    }
         $sql="insert INTO newsslider(image, thumbnail) VALUES ('$image_name', '$image_thumbnail')";
         mysql_query($sql,$connection);
         }
In detail, I want to upload two images from two separate browse button from my form and then store those into two separate fields (i.e. image_name and image_thumbnail) in table.
Here you can see that I have two input file type (img and img2) and I want to store those in two different fields (image_name and image_thumbnail) in a table.
Please suggest. Thanks in advance.
 
    