上传时,$ _FILES为空 [英] $_FILES Empty When Uploading

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

问题描述

在尝试访问 $ _ FILES 数组时,PHP返回错误

When trying to access the $_FILES array, PHP returns the error


Undefined index:picture。

"Undefined index: picture".

在我的 php.ini 文件,文件上传已打开,任何用户都可以在 / tmp 目录中写入。在HTML表单中,enctype被设置为multipart / form-data。有趣的是,上传文件的基本名称打印出来,所以我相信PHP实际上已经看到了该文件,但上传它的一些问题。
有人可以就这个问题的潜在解决方案提供建议吗?顺便说一下,我使用的是PHP5。

In my php.ini file, File Uploads are turned on, and any user can write in the /tmp directory. In the HTML form, enctype is set to "multipart/form-data". Interestingly enough, the basename for the uploaded file prints so I believe that PHP has actually seen the file, but has some problem uploading it. Can someone provides suggestions on potential solutions to this problem? By the way, I am using PHP5.

PHP文件片段

Snippets from PHP File

echo "Picture=" . $_POST['picture'] . "<br/>";
$uploadedPic = $_FILES['picture']['tmp_name'];

HTML表单

<form action="PHPFile.php" method="post" enctype="multipart/form-data">

<p> Picture </p>
<input type = "file" id="picture" name="picture"/>

</form>


推荐答案

如果它是 $ _ POST ['picture'] ,那么它的逻辑,你不会在 $ _ POST中找到上传的文件数据,它位于 $ _ FILES

On what line do you get that warning? If it is the one with $_POST['picture'], then its logical, you wont find uploaded file data in $_POST, it is in $_FILES

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

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