PHP文件上载给出了成功的错误代码,但没有显示图像
为了清晰起见,我将把它分成易于浏览和可读的部分 问题:PHP文件上载给出了成功的错误代码,但没有显示图像,php,file-upload,Php,File Upload,为了清晰起见,我将把它分成易于浏览和可读的部分 问题: <?php if(isset($_POST['submit'])){ echo $_FILES['a']['error']; if(isset($_FILE['a']['tmp_name'])){ echo "hello"; } } ?> <form action = "text.php" method
<?php
if(isset($_POST['submit'])){
echo $_FILES['a']['error'];
if(isset($_FILE['a']['tmp_name'])){
echo "hello";
}
}
?>
<form action = "text.php" method = "POST" enctype="multipart/form-data">
<label for = "a"> Send Image </label>
<input type = "file" name = "a" id = "a">
<input type = "submit" name = "submit" value = "Submit">
</form>
上传文件后,$\u FILES super global似乎没有保存任何信息。尽管如此,我还是得到了错误代码0(成功上传),这似乎是矛盾的
背景:
<?php
if(isset($_POST['submit'])){
echo $_FILES['a']['error'];
if(isset($_FILE['a']['tmp_name'])){
echo "hello";
}
}
?>
<form action = "text.php" method = "POST" enctype="multipart/form-data">
<label for = "a"> Send Image </label>
<input type = "file" name = "a" id = "a">
<input type = "submit" name = "submit" value = "Submit">
</form>
我已经在一个个人网站上工作了一段时间,现在正在开发一个帖子管理系统。到目前为止一切都很顺利,但我在尝试使用$\u文件上传图像时遇到了困难
我在学校和我的工作中做过很多次这样的事情,但是我的电脑似乎出了点问题,或者我有一个巨大的白痴中风
要解决此问题,我已经:
<?php
if(isset($_POST['submit'])){
echo $_FILES['a']['error'];
if(isset($_FILE['a']['tmp_name'])){
echo "hello";
}
}
?>
<form action = "text.php" method = "POST" enctype="multipart/form-data">
<label for = "a"> Send Image </label>
<input type = "file" name = "a" id = "a">
<input type = "submit" name = "submit" value = "Submit">
</form>
upload_max_filesize
和post_max_size
等值更改为100mUPLOAD\u ERR\u OK
<?php
if(isset($_POST['submit'])){
echo $_FILES['a']['error'];
if(isset($_FILE['a']['tmp_name'])){
echo "hello";
}
}
?>
<form action = "text.php" method = "POST" enctype="multipart/form-data">
<label for = "a"> Send Image </label>
<input type = "file" name = "a" id = "a">
<input type = "submit" name = "submit" value = "Submit">
</form>
发送图像
提交表单时,我会收到错误代码0,但hello测试语句不会触发。全局数组名为
$\u FILES
您正在检查isset($\u FILE['a']['tmp\u name']
如果您想检查上传的文件,请尝试使用
if (is_uploaded_file($_FILES['a']['tmp_name'])) {
//file is uploaded
}
好了。我想我预测了一个巨大的白痴中风是对的。谢谢!