我從Android端上傳文件(圖像,視頻和音頻)到PHP服務器。它適用於小文件。但是,對於大文件,它會給出意想不到的結果,比如文件上傳,但在android端,它會產生超時異常。 所以請幫助我,我如何解決文件上傳的所有場景。我如何使用HttpMultipart實體以及如何針對不同大小的文件設置相對超時。 我的代碼是:Android文件上傳使用loopj HttpClient
File myFile = new File(filePath);
RequestParams params = new RequestParams();
try {
params.put("uploaded_file", myFile);
} catch (FileNotFoundException e) {
}
URL=getResources().getString(com.newing.R.string.server_adderess)+URL+fileType+"&lessonID="+LessonID;
client.post(URL, params, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(String response) {
Log.w("async", "success!!!!");
UtilityFunctions.showNotification(getApplicationContext(),
"File uploading completed.");
stopSelf();
}
@Override
public void onFailure(Throwable error) {
Log.w("async", "failure!!!!");
UtilityFunctions.showNotification(getApplicationContext(),
"File couldn't upload. Please try later.");
stopSelf();
}
});
你可以檢查你的s上傳max_size限制erver?超時值? –