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 PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
