java - Upload image using POST, php and Android -
i getting following error message after trying upload image using multipartentity in android:
error: problem [picture] (file upload error 4) i using following code upload image:
string url = "http://www.uploadurl.com/api/files.php"; httpclient httpclient = new defaulthttpclient(); httpcontext localcontext = new basichttpcontext(); httppost httppost = new httppost(url); multipartentity multientity = new multipartentity(httpmultipartmode.browser_compatible); file file = new file(environment.getexternalstoragedirectory().getabsolutepath() + "/temp/" + image_filename); contentbody cbody = new filebody(file); stringbody sb1 = new stringbody(getnameformatted()); stringbody sb2 = new stringbody(getdeviceid()); multipartentity multipartcontent = new multipartentity(); multipartcontent.addpart("name", sb1); multipartcontent.addpart("uuid", sb2); multipartcontent.addpart("picture", cbody); httppost.setentity(multipartcontent); httpresponse response = httpclient.execute(httppost, localcontext); i'm not sure i'm doing wrong, have uploaded images using code similar in past using json array part of entity rather adding of them individually. think it's got way image set contentbody maybe? i'm not sure.
Comments
Post a Comment