Php 服务器 5.3.3 未在我的 Post 请求中检测到附件文件(5.4.3 检测到)
Php server 5.3.3 doesn't detect attachment file in my Post requests (5.4.3 does)
我正在使用 android volley - http 多部分请求 post 一个 mime 文件到我的 php 服务器。 Php 5.4.3 可以捕获附件,但 php 5.3.3 没有:
$_FILES['uploadedfile'] == empty array
(请求很好 - 请求长度很好)。
有人可以解释一下吗?为什么 php 5.3.3 没有?谢谢,我是 PHP.
的新人
How to send a “multipart/form-data” POST in Android with Volley
我的 http 请求:
{MultipartFormEntity@830061806024}
multipart = {HttpBrowserCompatibleMultipart@830061809784}
parts = {ArrayList@830059119584} size = 1
0 = {FormBodyPart@830067533016}
body = {ByteArrayBody@830067487680}
header = {Header@830067537968} "[Content-Disposition: form-data; name="uploadedfile"; filename="test.mim", Content-Type: application/octet-stream, Content-Transfer-Encoding: binary]"
name = {String@830059743272} "uploadedfile"
boundary = {String@830061809752} "6ANZ75BgJPrWEv1L0jU9o-IKj5ftRzcpKiBqY7N"
charset = {CharsetICU@830037109480} "java.nio.charset.CharsetICU[UTF-8]"
subType = {String@830057480912} "form-data"
contentType = {BasicHeader@830061692384} "Content-Type: multipart/form-data; boundary=6ANZ75BgJPrWEv1L0jU9o-IKj5ftRzcpKiBqY7N; charset=UTF-8"
name = {String@830037147880} "Content-Type"
value = {String@830061806056} "multipart/form-data; boundary=6ANZ75BgJPrWEv1L0jU9o-IKj5ftRzcpKiBqY7N; charset=UTF-8"
contentLength = 4299
此代码破坏了 php 函数:
try {
entityBuilder.setCharset(CharsetUtils.get("UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
>> Content-Type =
multipart/form-data; boundary=1ft_IEmfaejQeazBUZDaPUqA-bkzkalk0; charset=UTF-8
事实上,上面这段代码使 php 服务器无法获取上传的文件,因为它在边界部分之后有字符集类型。下面的内容类型使我的代码有效:
multipart/form-data; boundary=1ft_IEmfaejQeazBUZDaPUqA-bkzkalk0
我在某些版本中来宾,php 服务器在第一种情况下无法识别上传的文件。非常感谢BNK的建议。
我正在使用 android volley - http 多部分请求 post 一个 mime 文件到我的 php 服务器。 Php 5.4.3 可以捕获附件,但 php 5.3.3 没有:
$_FILES['uploadedfile'] == empty array
(请求很好 - 请求长度很好)。
有人可以解释一下吗?为什么 php 5.3.3 没有?谢谢,我是 PHP.
的新人How to send a “multipart/form-data” POST in Android with Volley
我的 http 请求:
{MultipartFormEntity@830061806024}
multipart = {HttpBrowserCompatibleMultipart@830061809784}
parts = {ArrayList@830059119584} size = 1
0 = {FormBodyPart@830067533016}
body = {ByteArrayBody@830067487680}
header = {Header@830067537968} "[Content-Disposition: form-data; name="uploadedfile"; filename="test.mim", Content-Type: application/octet-stream, Content-Transfer-Encoding: binary]"
name = {String@830059743272} "uploadedfile"
boundary = {String@830061809752} "6ANZ75BgJPrWEv1L0jU9o-IKj5ftRzcpKiBqY7N"
charset = {CharsetICU@830037109480} "java.nio.charset.CharsetICU[UTF-8]"
subType = {String@830057480912} "form-data"
contentType = {BasicHeader@830061692384} "Content-Type: multipart/form-data; boundary=6ANZ75BgJPrWEv1L0jU9o-IKj5ftRzcpKiBqY7N; charset=UTF-8"
name = {String@830037147880} "Content-Type"
value = {String@830061806056} "multipart/form-data; boundary=6ANZ75BgJPrWEv1L0jU9o-IKj5ftRzcpKiBqY7N; charset=UTF-8"
contentLength = 4299
此代码破坏了 php 函数:
try {
entityBuilder.setCharset(CharsetUtils.get("UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
>> Content-Type =
multipart/form-data; boundary=1ft_IEmfaejQeazBUZDaPUqA-bkzkalk0; charset=UTF-8
事实上,上面这段代码使 php 服务器无法获取上传的文件,因为它在边界部分之后有字符集类型。下面的内容类型使我的代码有效:
multipart/form-data; boundary=1ft_IEmfaejQeazBUZDaPUqA-bkzkalk0
我在某些版本中来宾,php 服务器在第一种情况下无法识别上传的文件。非常感谢BNK的建议。