Php 同时使用reCAPTCHA和enctype=“多部分/表单数据”
我有一个文件上传表单,我还想在上面使用Google reCAPTCHA 如果我有以下几点Php 同时使用reCAPTCHA和enctype=“多部分/表单数据”,php,recaptcha,enctype,Php,Recaptcha,Enctype,我有一个文件上传表单,我还想在上面使用Google reCAPTCHA 如果我有以下几点 <form method="post"> <input type="file" name="filename"> <div class="g-recaptcha" data-sitekey="***"></div> <input id="submit" name="submit" type="submit" value="Subm
<form method="post">
<input type="file" name="filename">
<div class="g-recaptcha" data-sitekey="***"></div>
<input id="submit" name="submit" type="submit" value="Submit">
</form>
我可以使用reCAPTCHA,但无法上载文件
但是,如果我使用:
<form method="post" enctype="multipart/form-data">
<input type="file" name="filename">
<div class="g-recaptcha" data-sitekey="***"></div>
<input id="submit" name="submit" type="submit" value="Submit">
</form>
我可以成功上传该文件,并使用reCAPTCHA,前提是该文件是文本文件。如果我试图上传一个pdf文件,我就无法让它工作
上载文本文件时,$\u POST包含“g-recaptcha-response”,但上载pdf时,$\u POST不包含“g-recaptcha-response”
有人能解释一下这里出了什么问题吗
编辑
看起来这实际上是一个文件大小问题。
大于~200kb的文件不能以任何格式发送
我在php.ini文件中上传了\u max\u filesize=2M,所以我不确定为什么200kb太大
有什么想法吗
编辑2:更多信息
看起来$\u文件包含错误代码3:UPLOAD\u ERR\u PARTIAL
我不明白为什么文件不能完全上传
编辑3:有所收获
我现在可以上传文件了。似乎我需要将reCAPTCHA放在文件输入之前
<form method="post" enctype="multipart/form-data">
<div class="g-recaptcha" data-sitekey="***"></div>
<input type="file" name="filename">
<input id="submit" name="submit" type="submit" value="Submit">
</form>
有人能详细说明为什么会出现这种情况吗
编辑4:发言太早
切换顺序会使g-recaptcha-response“出现在$\u POST中,但我仍然收到错误代码3:UPLOAD\u ERR\u PARTIAL
编辑5
看起来文件上传正确,因为我可以在firefox调试器的头参数中看到它。看起来php只是没有正确地填充$\u文件数组…我在不同的服务器上尝试了相同的代码,效果很好 看起来问题在于我设置的服务器存在某种配置问题。它实际上与reCAPTCHA和file input+enctype的交互无关 如果我发现了什么是配置问题,我将进行更新