-2
我試圖從存儲器上傳映像到服務器。我在這裏做錯了什麼?我需要爲此使用PHP腳本嗎?無法使用快速Android網絡庫將映像上載到服務器
私有類UploadImage擴展的AsyncTask {
File picPath;
String picName;
public UploadImage(File picPath, String picName){
this.picPath= picPath;
this.picName = picName;
}
@Override
protected Void doInBackground(Void... params) {
String uril = getResources().getString(R.string.ServerPath) + "MyFiles/" + picName;
AndroidNetworking.upload(uril)
.addMultipartFile(picName, picPath)
.addMultipartParameter("key","value")
.setPriority(Priority.MEDIUM)
.build()
.setUploadProgressListener(new UploadProgressListener() {
@Override
public void onProgress(long bytesUploaded, long totalBytes) {
if (bytesUploaded == totalBytes){
Toast.makeText(getApplicationContext(), "Image Uploaded!",Toast.LENGTH_SHORT).show();
}
}
});
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
Toast.makeText(getApplicationContext(), "Uploaded!",Toast.LENGTH_SHORT).show();
}
}