为什么将文件上传到 PHP 时 $_FILES 为空?
我的 Windows 7 计算机上安装了 WampServer 2.我正在使用 Apache 2.2.11 和 PHP 5.2.11.当我尝试从表单上传任何文件时,它似乎在上传,但在 PHP 中,$_FILES
数组为空.c:wamp mp
文件夹中没有文件.我已配置 php.ini
以允许文件上传等.tmp
文件夹对当前用户具有读/写权限.我被难住了.
I have WampServer 2 installed on my Windows 7 computer. I'm using Apache 2.2.11 and PHP 5.2.11. When I attempt to upload any file from a form, it seems to upload, but in PHP, the $_FILES
array is empty. There is no file in the c:wamp mp
folder. I have configured php.ini
to allow file uploads and such. The tmp
folder has read/write privileges for the current user. I'm stumped.
HTML:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<form enctype="multipart/form-data" action="vanilla-upload.php" method="POST">
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>
PHP:
<?php
echo 'file count=', count($_FILES),"
";
var_dump($_FILES);
echo "
";
?>
推荐答案
感谢大家的各种全面回复.这些都非常有帮助.答案竟然是非常奇怪的.事实证明,PHP 5.2.11 不喜欢以下内容:
Thank you everybody for the vary comprehensive replies. Those are all very helpful. The answer turned out to be something very odd. It turns out that PHP 5.2.11 doesn't like the following:
post_max_size = 2G
或
post_max_size = 2048M
如果我将其更改为 2047M
,则可以上传.
If I change it to 2047M
, the upload works.
相关文章