Why would $_FILES be empty when uploading files to PHP?(为什么将文件上传到 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.
这篇关于为什么将文件上传到 PHP 时 $_FILES 为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么将文件上传到 PHP 时 $_FILES 为空?


- PHP foreach() 与数组中的数组? 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- PHP - if 语句中的倒序 2021-01-01