title: simple file upload script
body: <p>I have written a simple file upload script but it gives me the error of undefined index file1.</p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;form method="post"&gt;
              &lt;label for="file"&gt;Filename:&lt;/label&gt;
              &lt;input type="file" name="file1" id="file1" /&gt; 
              &lt;br /&gt;
              &lt;input type="submit" name="submit" value="Submit" /&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  &lt;?php
  if(isset($_POST['submit'])) {
      if ($_FILES["file1"]["error"] &gt; 0) {
          echo "Error: " . $_FILES["file1"]["error"] . "&lt;br /&gt;";
      } else {
          echo "Upload: " . $_FILES["file1"]["name"] . "&lt;br /&gt;";
          echo "Type: " . $_FILES["file1"]["type"] . "&lt;br /&gt;";
          echo "Size: " . ($_FILES["file1"]["size"] / 1024) . " Kb&lt;br /&gt;";
          echo "Stored in: " . $_FILES["file1"]["tmp_name"];
      }
  }
  ?&gt;
  </code></pre>
  
  <p>What is the problem in code?</p>