php image file upload- php× 241958
<p>I'm new to PHP and copied this code from a book. In the file upload.html:</p>

<pre><code> &lt;form method="POST" action="do_upload.php" enctype="multipart/form-data"&gt;
 &lt;input type="file" name="img1" size="30"&gt;&lt;/p&gt;
</code></pre>

<p>In the PHP script do_upload.php:</p>

<pre><code>if($_FILES["img1"] != "") {
    echo "file selected"; else die("Couldnot copy the file");
}
</code></pre>

<p>But I got a error saying:</p>

<blockquote>
  <p>Undefined index: img1 in C:\xampp\htdocs\test23\do_upload.php on line
  2</p>
</blockquote>

<p>Why is img1 termed as <code>undefined index</code> even though <code>name="img1"</code> is in
upload.html?</p>
