上传php中的文件无法正常工作

Can anyone help me solve this problem of file upload in php. I am getting undefined index at line! The codes are in two seperate files. I tried several codes, still not working. Please help. Thank you all in advance. HTML File

<form role="form" name="uploadPro" id="uploadPro" method="post" action="upload.php" enctype="multipart/form-data">
    <div class="col-lg-6">
         <div class="form-group">
                <label>Product Tags</label>
                <textarea class="form-control" rows="2" name="pTags" id="PTags"></textarea>
                <p class="help-block">Add Tags to your products to enable faster search.</p>
          </div>
          <div class="form-group">
                <label>Product Expiry Date</label>
                 <input type="text" name="pExpDate" id="datepicker" class="form-control">
                <p class="help-block">Until which date will product be displayed.</p>
          </div>
          <div class="form-group">
                <label>Upload Main Image</label>
                <input type="file" name="mainPath" id="mainPath">
                <p class="help-block">This image will appear everywhere. Make sure it has a good quality to impress users and size greater than 400px X 400px. </p>
          </div>
          <div class="form-group">
                <label>Upload Sub Image 1</label>
                <input type="file" name="sub1"  id="sub1">
                <p class="help-block">Make sure image has a good quality to impress users and size greater than 400px X 400px. </p>
          </div>
          <div class="form-group">
                <label>Upload Sub Image 2</label>
                <input type="file" name="sub2" id="sub2">
                <p class="help-block">Make sure image has a good quality to impress users and size greater than 400px X 400px. </p>
          </div>
          <div class="form-group">
                <label>Upload Sub Image 3</label>
                <input type="file"  name="sub3" id="sub3">
                <p class="help-block">Make sure image has a good quality to impress users and size greater than 400px X 400px. </p>
          </div>

           <input type="submit" value="Upload Image" name="submit" class="btn btn-default">
    </div>

</form>

PHP Code

if(isset($_POST['submit'])){

    /*Uploading main image*/
    $filetmp = $_FILES["mainPath"]["tmp_name"];//getting error here
    $filename = $_FILES["mainPath"]["name"];//getting error here
    $filepath = "../uploads/".$filename;
    move_uploaded_file($filetmp, $filepath);

    /*Uploading sub image1*/
    $filetmp1 = $_FILES["sub1"]["tmp_name"];//getting error here
    $filename1 = $_FILES["sub1"]["name"];//getting error here
    $filepath1 = "../uploads/".$filename1;
    move_uploaded_file($filetmp1, $filepath1);

    /*Uploading sub image2*/
    $filetmp2 = $_FILES["sub2"]["tmp_name"];//getting error here
    $filename2 = $_FILES["sub2"]["name"];//getting error here
    $filepath2 = "../uploads/".$filename2;
    move_uploaded_file($filetmp2, $filepath2);

    /*Uploading sub image3*/
    $filetmp3 = $_FILES["sub3"]["tmp_name"];//getting error here
    $filename3 = $_FILES["sub3"]["name"];//getting error here
    $filepath3 = "../uploads/".$filename3;
    move_uploaded_file($filetmp3, $filepath3);
}

First, ensure that PHP is configured to allow file uploads.

In your "php.ini" file, search for the file_uploads directive, and set it to On:

file_uploads = On

Error Messages Explained

PHP returns an appropriate error code along with the file array. The error code can be found in the error segment of the file array that is created during the file upload by PHP. In other words, the error might be found in $_FILES['userfile']['error'].

First use print_r($_FILES) to check if the values r posting.

Use for loop instead of accessing index,

if(isset($_POST['submit'])){

foreach ($_FILES as $row) {
     $filetmp = $row['tmp_name']; //getting error here
     $filename = $row["name"]; //getting error here
     $filepath = "../uploads/" . $filename;
     move_uploaded_file($filetmp, $filepath);
}

I can check you code in my test file and its working file it may be issue is on your "php.ini" file. please send me your error so i can identify.

I did not change anything. I restarted my Wamp server and run the page in incognito window. Its working now. Thank you all for your help. It makes me really happy to see how you help each other.