PHP HTML FORM发送_POST数据,但不是_FILES [英] PHP HTML FORM sends _POST data but not _FILES
本文介绍了PHP HTML FORM发送_POST数据,但不是_FILES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
表格:
< form class =form-inlineaction =#id =loginmethod =post>
< input type =filename =fileid =file>
< input type =hiddenname =testvalue =testy>
< input class =btn btn-primary btn-blocktype =submitname =submitvalue =Go>
< / form>
testy
的值恰好,但没有_FILES上传后。
当我从一个页面发送到另一个页面时,这起作用,但由于我将它全部移到同一页面上,它不再有效。我缺少什么?
$ _ POST ['test']
shows testy < code $
显示空白
$ b $ p $ $ FILES ['file']
解决方案
您的表单中需要 enctype =multipart / form-data
属性:
< form class =form-inlineaction =#id =loginmethod =postenctype =multipart /表单数据>
< input type =filename =fileid =file>
< input type =hiddenname =testvalue =testy>
< input class =btn btn-primary btn-blocktype =submitname =submitvalue =Go>
< / form>
I have a form that sends a file, yet it's not being able to be called after submit.
Form:
<form class="form-inline" action="#" id="login" method="post">
<input type="file" name="file" id="file">
<input type="hidden" name="test" value="testy">
<input class="btn btn-primary btn-block" type="submit" name="submit" value="Go">
</form>
The value of testy
comes up just fine, but nothing from _FILES after it's uploaded.
This was working when I was sending from one page to another page, but since I moved it all to happen on the same page, it's no longer working. What am I missing?
$_POST['test']
shows testy
$_FILES['file']
shows empty
解决方案
You need enctype="multipart/form-data"
attribute in your form:
<form class="form-inline" action="#" id="login" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file">
<input type="hidden" name="test" value="testy">
<input class="btn btn-primary btn-block" type="submit" name="submit" value="Go">
</form>
这篇关于PHP HTML FORM发送_POST数据,但不是_FILES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文