I'm using android volley - http multipart request to post a mime file to my php server. Php 5.4.3 can catch the attachment file but php 5.3.3 didn't:
$_FILES['uploadedfile'] == empty array
(the request is good - good request length).
Can someone explains? Why php 5.3.3 didn't? Thanks, I'm new in PHP.
How to send a “multipart/form-data” POST in Android with Volley
My http request:
{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:
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. The Content-Type below make my code works:
multipart/form-data; boundary=1ft_IEmfaejQeazBUZDaPUqA-bkzkalk0
I guest in some version, php server dont recognize uploaded file in first case. Thanks BNK very much for your suggestion.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.