简体   繁体   English

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)

I'm using android volley - http multipart request to post a mime file to my php server. 我正在使用android volley-HTTP multipart请求将mime文件发布到我的php服务器。 Php 5.4.3 can catch the attachment file but php 5.3.3 didn't: PHP 5.4.3可以捕获附件文件,但PHP 5.3.3没有:

$_FILES['uploadedfile'] == empty array

(the request is good - good request length). (请求很好-请求长度很好)。

Can someone explains? 有人可以解释吗? Why php 5.3.3 didn't? 为什么PHP 5.3.3没有? Thanks, I'm new in PHP. 谢谢,我是PHP新手。

How to send a “multipart/form-data” POST in Android with Volley 如何通过Volley在Android中发送“多部分/表单数据” POST

My http request: 我的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

This code broke php function: 此代码破坏了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

In fact, this code above made php server doesn't get the uploaded file since it having charset type after boundary part. 实际上,上面的这段代码使php服务器无法获取上载的文件,因为它在边界部分之后具有字符集类型。 The Content-Type below make my code works: 下面的Content-Type使我的代码有效:

    multipart/form-data; boundary=1ft_IEmfaejQeazBUZDaPUqA-bkzkalk0

I guest in some version, php server dont recognize uploaded file in first case. 我以某些版本来宾,PHP服务器在第一种情况下无法识别上传的文件。 Thanks BNK very much for your suggestion. 非常感谢BNK的建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM