Invalid file type – problem

Creating a field for uploading files, here is a page for uploading pictures:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title> INPUT,  accept</title>
 </head>
 <body> 
  <form action="handler.php">
   <p><strong>    JPEG, PNG  GIF</strong></p>
   <p><input type="file" name="img" accept="image/jpeg,image/png,image/gif">
   <input type="submit" value=""></p>
  </form>
 </body>
</html>

Here is handler.php:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title> INPUT,  accept</title>
 </head>
 <body> 
 <?
if (empty($_FILES['img']['tmp_name'])) die('  !');
$tmp = $_FILES['img']['tmp_name'];
$fname = $_FILES['img']['name'];
if (!move_uploaded_file($tmp, 'wp-content/uploads/'.$fname)) die('      ');
echo '<img src="/wp-content/uploads/'.$fname.'" />'; //  
?>
 </body>
</html>

When uploading any files (I tried to upload pictures and archives), it says that the file type is invalid, although I allowed the upload of images:

<input type="file" name="img" accept="image/jpeg,image/png,image/gif">

What’s the problem then?


Answer 1, authority 100%

The form does not have: method="post" enctype="multipart/form-data". It is natural that get’om does not want to send a file. =)
And the accept in the input is for the user’s convenience: some browsers limit the file selection to those specified in the accept.


Answer 2, authority 33%

Corrected the code, taking into account your wishes.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title> </title>
</head>
<body>
<strong><label style="color:#36C;">   </label></strong><br />
1.    - 2,9 .<br />
2.   - JPG.<br />
3. ()   ,<br />
       <br />
    .
<form enctype="multipart/form-data" action="?l=down" method="post" />
<input type="hidden" name="MAX_FILE_SIZE" value="3000000" />
 ""     : <br />
<input name="userfile" type="file" />
<input type="submit" value="" />
</form>
<?php
if ($_GET['l'] == 'down' ){
    $fn         =   $_FILES['name'];
    $ft         =   $_FILES['userfile'];
    $orn        =   $_FILES['userfile']['name'];
    $ext        =   substr($_FILES['userfile']['name'], -3);
    $allowTypes =   array ('jpg', 'jpeg', 'png', 'gif', 'txt');
    if (false !== array_search($ext, $allowTypes)) {
        $uploaddir = './wp-content/uploads/';
        $uploadfile = $uploaddir.$_FILES['userfile']['name'];
        if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
            echo ' ,  ,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="?"> </a><br />'.'<input size="40" type="text" value="'.substr($uploadfile, 1).'" /><br />';
            echo '<input type="button" onclick="document.getElementById(\'dimg1\').innerHTML=\'<img src=.'.substr($uploadfile, 1).' />\'" value=" " /><br />';
            echo '<div id="dimg1"></div>';
        } else {
            echo '  ';
        }
    } else {
        echo '      ';
    }
}
#
?>
</body>
</html>