为什么$文件上传到PHP的时候_FILES是空的? [英] Why would $_FILES be empty when uploading files to PHP?

查看:315
本文介绍了为什么$文件上传到PHP的时候_FILES是空的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有WampServer 2我的Windows 7计算机上安装。我使用Apache 2.2.11和5.2.11 PHP。当我尝试从形式上传任何文件,它似乎上传,但是在PHP中的 $ _ FILES 数组为空。有一个在 C无文件:\\ WAMP \\ tmp目录文件夹中。我已经配置的php.ini 允许文件上传和这样的。在 TMP 文件夹具有读/写权限当前用户。我难倒。

HTML:

 < HTML和GT;
< HEAD>
    < META HTTP-EQUIV =Content-Type的CONTENT =text / html的;字符集= UTF-8/>
< /头>
<身体GT;
    <表单的enctype =的multipart / form-data的行动=香草upload.php的方法=POST>
        选择要上传的文件:其中,输入名称=UploadedFile的TYPE =文件/>< BR />
        <输入类型=提交值=上传文件/>
    < /表及GT;
< /身体GT;
< / HTML>

PHP:

 < PHP
回声'文件数=',计数($ _ FILES),\\ n;
后续代码var_dump($ _ FILES);
回声\\ n;
?>


解决方案

感谢您为每个人都各不相同的COM prehensive回复。这些都是非常有益的。答案竟然是一件很奇怪的。事实证明,PHP 5.2.11不喜欢以下内容:

  post_max_size要= 2G

  post_max_size要2048M =

如果我将其更改为 2047M ,上传作品。

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\tmp 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),"\n";
var_dump($_FILES);
echo "\n";
?>

解决方案

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

or

post_max_size = 2048M

If I change it to 2047M, the upload works.

这篇关于为什么$文件上传到PHP的时候_FILES是空的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆