- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在做一个用户注册是一个小模块的项目。我在这里使用了一些参数,例如姓名、电子邮件、联系方式、年龄、地址和个人资料图片。
//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 Reuest 将用户数据存储到服务器
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);
}
这是我上传图片的PHP代码
$file_upload_url = __DIR__."/Upload/". $target_path;
// Get file name posted from Android App
$filename = 'user_'.$name.'_Profilepic'.'.png';
//check if the directory exists
if(!file_exists($file_upload_url)){
if(!mkdir($file_upload_url,0755,true)){
$error = error_get_last();
echo $error['message'];
echo 'failed';
}
}
// Decode Image
$binary=base64_decode($profile_pic);
header('Content-Type: image/png');
$file = fopen($file_upload_url.$filename, 'wb');
// Create File
fwrite($file, $binary);
fclose($file);
这也是我的 .htaccess 文件设置
php_value memory_limit 128M
php_value post_max_size 500M
php_value upload_max_filesize 500M
下面的问题是,当我在本地主机上运行整个程序时,它按预期工作,但在服务器上,我从截击中得到了这个错误
BasicNetwork.performRequest: Unexpected response code 413
Solved
问题出在服务器上,因为它是共享主机,文件上传限制受到限制。
最佳答案
就我而言,问题的答案是我使用的主机是共享主机。
而且帖子大小有限制,所以我们要用
更新.htaccess
文件
post_max_size
& upload_max_size
。
关于php - Volley BasicNetwork.performRequest : Unexpected response code 413,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37165874/
我正在尝试使用 encog 库作为强化学习问题的函数逼近器。更准确地说,我正在尝试启动并运行一个多层感知器 (BasicNetwork)。 由于我的代理会根据我选择的任何 RL 算法以某种方式探索世界
我试图通过 volley 库向我的服务器发送一个发布请求。但它不起作用。我已经在 Postman 中测试了我的 API,它在那里工作。我使用了相同的参数。 我得到的错误: BasicNetwork.p
我在使用 volley 库发出网络请求时遇到此错误,我已点击这些链接 Android Volley - BasicNetwork.performRequest: Unexpected response
当我尝试使用 Volley StringRequest 或 JsonObjectRequest 通过 rest api 获取数据时。我总是收到 400 错误。它与 postman 合作良好。 http
我想从数据库中获取用户的信息并显示出来,但我一直收到这个错误: BasicNetwork.performRequest: Unexpected response code 404 这是我的javaco
为什么当我点击“登录”按钮时出现此错误:“E/Volley: [126] BasicNetwork.performRequest: 意外响应代码 500”? PS:它适用于本地,因此适用于本地数据库。
对于我的移动应用程序,我使用 Android Pay + Stripe 作为支付网关。我使用 Stripe 创建了一个商家帐户,并使用 PUBLISHABLE key 生成了一个 token 。在过去
我正在尝试将数据从 Android 应用程序发送到 Servlet。我的 Android 应用程序运行正常。 问题仅与发送到 Servlet 的请求有关。它给出错误 BasicNetwork.perf
我最近开始开发我的 Android 应用程序,我需要一个登录和注册系统。我在 androidhive.info 上找到了一个教程,但我经常遇到错误。我正在使用 volley 库发送 HTTP 请求,L
我正在做一个用户注册是一个小模块的项目。我在这里使用了一些参数,例如姓名、电子邮件、联系方式、年龄、地址和个人资料图片。 //Here is my Android part Code Where Pr
问题陈述: 我正在尝试访问一个 REST API,该 API 将使用 Volley 为各种 HTTP 状态代码(400、403、200 等)返回一个 JSON 对象。 对于 200 以外的任何 HTT
我的第一个帖子:Anything I try to store on database enters with value '0' 我解决了这个问题,但现在我遇到了另一个问题:为什么我尝试登录时出现此
使用 Volley,我 POST StringRequest 并且当我访问 url 时出现错误,因为它是 https://www.google.com/?gfe_rd=cr&ei=vX8jVdTvOs
我在我的 android samsung 上尝试下面的代码,它给出了错误。 (我要获取 channel 属性) String URL = "https://www.googleapis.com/you
我正在尝试通过 POST 将 json obj 通过 volley 在我的 android 应用程序中发送到 api 并捕获 json 响应,但我不断收到此错误: E/Volley:[194] Bas
API 是在 Wordpress 中使用 POST 方法开发的。 API 在 POSTMAN 和 iOS(swift) 中运行良好。我在 POSTMAN 中收到回复,我的同事 iOS 开发人员也收到回
我正在使用 Volley 连接到 MySql 数据库。我创建了数据库表并编写了 php 函数,下面是 java 代码。所有这一切一直有效,但就在昨天,它醒来时在 logcat 中给出了这个错误并且它没
我遇到了这个错误,我不确定如何解决这个问题。尝试了很多搜索,但没有任何进展。 这是错误 BasicNetwork.performRequest: Unexpected response code 40
也许这个问题之前已经发布过,但它并没有解决我的问题。我正在尝试使用 laravel 作为后端将数据从 android 发送到 mysql 数据库。我开发了restful Api。这是我的代码。
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
我是一名优秀的程序员,十分优秀!