我正在使用带有Expressons Web 4,MySql,IE 11和PHP 5.6.5的Windows 8.1系统 . I.m使用以下代码来自教程:

<form action="upload.php" method="post" enctype="multipart/form-data" >
    <input type="text" name="testtext" />
    
Select image to upload: <input type='hidden' name='maxfilesize' value='2000000'/> <input type="file" name="filename" id="fileToUpload" /> <input type="submit" value="UploadImage" name="submit" /> </form>

这个饲料upload.php:

<?  
    echo '$_POST: ';
    var_dump($_POST);
    echo '
$_FILES: '; var_dump($_FILES); echo '
Target_Directory: '; $target_dir = "../Home/"; echo $target_dir . '
' ; echo basename($_FILES["filename"]["name"]) . '
'; $target_file = $target_dir . basename($_FILES["filename"]["name"]); echo $target_file . '
' ; $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); echo $imageFileType . '
' ; // Check if image file is a actual image or fake image if(isset($_POST["submit"])) { $check = getimagesize($_FILES["filename"]["tmp_name"]); if($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } }

无论我尝试上传什么,$ _POST和$ _FILES数组都显示为空 . 即使是10K .png文件 . 如果我用type ='file'注释掉输入,$ _POST数组将填充第一个输入的数据 . 如果我留下它,无论我做什么,两个阵列都是空的 .

我的php.ini文件有以下设置:

  • file_upload =开

  • upload_max_filesize = 4M

  • max_file_uploads = 20

  • post_max_size = 16M

我经历了另一个例子中的12点检查,但没有看到任何与众不同的东西 . 我已经审查了至少50个其他建议,但没有找到任何可以解决此问题的建议 . 这可能是我忽视的东西,但似乎无法找到它 .

与此问题相关的日志文件中未发布任何错误 . 他们确实有效,因为其中有其他错误 .

输出显示两个数组为空:

$_POST: array(0) { } 
$_FILES: array(0) { } 
Target_Directory: ../Home/
Notice: Undefined index: filename in C:\Users\EE\My Web Sites\timetubes\Home\upload.php on line 30 
Notice: Undefined index: filename in C:\Users\EE\My Web Sites\timetubes\Home\upload.php on line 31 ../Home/

删除了编码类型的输出(从表单标记中删除了enctype =“multipart / form-data”,以证明页面确实传递了没有enctype的变量):

$_POST: array(4) { ["testtext"]=> string(4) "test" ["maxfilesize"]=> string(7) "2000000" ["fileToUpload"]=> string(71) "C:\Users\EE\My Web Sites\timetubes\images\skins\medieval\tube-ghost.png" ["submit"]=> string(11) "UploadImage" } 
    $_FILES: array(0) { } 
    Target_Directory: ../Home/
    Notice: Undefined index: filename in C:\Users\EE\My Web Sites\timetubes\Home\upload.php on line 30 
    Notice: Undefined index: filename in C:\Users\EE\My Web Sites\timetubes\Home\upload.php on line 31 ../Home/

任何帮助表示赞赏!