Php 使用带有android应用程序错误的URL在服务器上保存图像第1行第1列路径处输入错误结束$
我有一个Php 使用带有android应用程序错误的URL在服务器上保存图像第1行第1列路径处输入错误结束$,php,android,image,retrofit,Php,Android,Image,Retrofit,我有一个android应用程序,用户从图库中选择一个图像,然后当他保存它时,图像保存在我的服务器上的上传文件夹中,MySQL表中保存图像url 我使用改装保存照片 我有一个问题,当用户选择照片并保存它时,应用程序在第1行第1列路径$处返回错误输入结束,,但照片完全保存在服务器上,url保存在MySQL上 但是,我应该得到Toast消息,而不是在第1行第1列路径$处接收输入结束错误 我如何才能停止接收错误消息 main活动 Img_Pojo up.php 当您的响应完全为空时,会发生此错误。所以检
android应用程序
,用户从图库
中选择一个图像
,然后当他保存它时,图像
保存在我的服务器
上的上传
文件夹中,MySQL
表中保存图像url
我使用改装
保存照片
我有一个问题,当用户选择照片
并保存它时,应用程序在第1行第1列路径$处返回错误输入结束,,但照片完全保存在服务器上,url保存在MySQL上
但是,我应该得到Toast消息,而不是在第1行第1列路径$
处接收输入结束错误
我如何才能停止接收错误消息
main活动
Img_Pojo
up.php
当您的响应完全为空时,会发生此错误。所以检查您必须检查php文件 正如我所看到的,您从未返回或打印输出以从android接收它 将这一行添加到php文件的末尾
echo json_encode($output);
对不起,毕加索和格莱德不是用来显示图像的库?在我的例子中,图像必须保存而不显示。你是对的,我没有注意到,我忘记了把
echo-json\u-encode($output)代码>,非常感谢您的帮助,我将您的代码添加到我的答案中以帮助他人。
@FormUrlEncoded
@POST("up.php")
Call<Img_Pojo> uploadImage(@Field("image_name") String title, @Field("image") String image);
private static final String BaseUrl = "https://provaord.altervista.org/OrdPlace/image2/";
private static Retrofit retrofit;
public static Retrofit getApiClient() {
retrofit = new Retrofit.Builder().baseUrl(BaseUrl).
addConverterFactory(GsonConverterFactory.create()).build();
return retrofit;
}
private String Title;
private String Image;
private int isSuccess;
private String message;
public Img_Pojo(String Title, String Image, int isSuccess, String message) {
this.Title = Title;
this.Image = Image;
this.isSuccess = isSuccess;
this.message = message;
}
public String getTitle() {
return Title;
}
public void setTitle(String title) {
this.Title = title;
}
public String getImage() {
return Image;
}
public void setImage(String image) {
this.Image = image;
}
public int getIsSuccess() {
return isSuccess;
}
public void setIsSuccess(int success) {
this.isSuccess = success;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
<?php
$image_name = $_POST['image_name'];
$image = $_POST['image'];
$path = "imagini/$image_name.jpg";
$output=array();
//require database
require_once('db.php');
$conn=$dbh->prepare('INSERT INTO volley_upload(image_name,image_path) VALUES (?,?)');
//encrypting the password
$conn->bindParam(1,$image_name);
$conn->bindParam(2,$path);
$conn->execute();
file_put_contents($path,base64_decode($image));
if($conn->rowCount() == 0)
{
$output['isSuccess'] = 0;
$output['message'] = "Registrazione fallita, riprovare.";
}
elseif($conn->rowCount() !==0){
$output['isSuccess'] = 1;
$output['message'] = "Informazioni base inserite!";
}
?>
echo json_encode($output);