Php Volley BasicNetwork.performRequest:意外响应代码413
我正在做一个项目,用户注册是一个小模块。在这里,我选择了一些参数,如姓名、电子邮件、联系人、年龄、地址和个人资料Php Volley BasicNetwork.performRequest:意外响应代码413,php,android,android-volley,Php,Android,Android Volley,我正在做一个项目,用户注册是一个小模块。在这里,我选择了一些参数,如姓名、电子邮件、联系人、年龄、地址和个人资料 //Here is my Android part Code Where Profile_pic is the compressed byte[] of an image 这是我的byte[]压缩方法 public static byte[] compress(byte[] data) throws IOException { Deflater deflater = new
//Here is my Android part Code
Where Profile_pic is the compressed byte[] of an image
这是我的byte[]压缩方法
public static byte[] compress(byte[] data) throws IOException {
Deflater deflater = new Deflater();
deflater.setInput(data);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);
deflater.finish();
byte[] buffer = new byte[1024];
while (!deflater.finished()) {
int count = deflater.deflate(buffer);
outputStream.write(buffer, 0, count);
}
outputStream.close();
byte[] output = outputStream.toByteArray();
return output;
}
Android Volley重新尝试将用户数据存储到服务器
public void addUser(final String name, final String email, final String mobile, final String password, final String dob,
final String gender, final String address, final String profile_pic, final String latLng,
final String city, final String state, final String country, final String postalcode) {
StringRequest strReq = new StringRequest(Request.Method.POST,
AppConfig.URL_REQUEST_SMS, new Response.Listener<String>() {
public String addresse;
@Override
public void onResponse(String response) {
System.out.println("1");
try {
JSONObject responseObj = new JSONObject(response);
boolean error = responseObj.getBoolean("error");
String message = responseObj.getString("message");
if (!error) {
......
} else {
Toast.makeText(context,
"Error: " + message,
Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
Toast.makeText(context,
"Error: " + e.getMessage(),
Toast.LENGTH_LONG).show();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(context,
error.getMessage() , Toast.LENGTH_SHORT).show();
}
}) {
/**
* Passing user parameters to our server
* @return
*/
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("name", name);
params.put("email", email);
params.put("mobile", mobile);
params.put("password", password);
params.put("dob", dob);
params.put("gender", gender);
params.put("address", address);
params.put("profile_pic", profile_pic);
params.put("latLng", latLng);
params.put("color", String.valueOf(color));
params.put("user_level", "patient");
params.put("city", city);
params.put("state", state);
params.put("country", country);
params.put("postalcode", postalcode);
return checkParams(params);
}
private Map<String, String> checkParams(Map<String, String> map) {
for (Map.Entry<String, String> pairs : map.entrySet()) {
if (pairs.getValue() == null) {
map.put(pairs.getKey(), "");
}
}
return map;
}
};
strReq.setShouldCache(false);
// Adding request to request queue
AppController.getInstance().addToRequestQueue(strReq);
}
这里还有我的.htaccess文件设置
php_value memory_limit 128M
php_value post_max_size 500M
php_value upload_max_filesize 500M
下面的问题是,当我在localhost中运行整个程序时,它会按预期工作,但在服务器上,我从截击中得到这个错误
BasicNetwork.performRequest: Unexpected response code 413
解决
问题出在服务器上,因为它是共享主机,文件上载限制受到限制。在我的情况下,问题的答案是我使用的主机是共享主机 而且帖子大小有限制,因此我们要使用更新
.htaccess
文件
post_max_size
和upload_max_size
请不要在问题中包括您是如何解决问题的。相反,在下面贴一个答案,这样其他人就会知道这个问题已经得到了回答。
BasicNetwork.performRequest: Unexpected response code 413