java - Uploading Image using Base64 results in error 413 -
so i'm moving hosting packages bluehost namecheap. i'm developing android application university problem. image upload worked fine on bluehost webhost. when try same technique run error.
i've done debugging , have come conclusion it's server-side related it's same code parameters changed , nothing on android throws errors whatsoever. entries added database image doesn't uploaded (registration system).
error:
413 request entity large request entity large requested resource not allow request data requests, or amount of data provided in request exceeds capacity limit. additionally, 404 not found error encountered while trying use errordocument handle request.
php code:
$user = $_post['username']; $base = $_request['image']; $binary = base64_decode($base); header('content-type: bitmap; charset=utf-8'); mkdir('../usr/'.$user); $file = fopen('../usr/'.$user.'/display_picture.png', 'wb'); fwrite($file, $binary); fclose($file);
java code: (just incase)
public void uploaddisplaypicture(final progressdialog uploadingimage) { final string upload_display_picture = "upload display picture"; new asynctask<void, void, string>() { @override protected string doinbackground(void... params) { log.d(upload_display_picture,"do in background running"); inputstream is; try { arraylist<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(); namevaluepairs.add(new basicnamevaluepair("username", registrationdetails[0])); namevaluepairs.add(new basicnamevaluepair("image", encodedstring)); httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(config.ip + config.display_photo_path); httppost.setentity(new urlencodedformentity(namevaluepairs)); httpresponse response = httpclient.execute(httppost); httpentity entity = response.getentity(); = entity.getcontent(); bufferedreader reader = new bufferedreader(new inputstreamreader(is, "iso-8859-1"), 8); stringbuilder sb = new stringbuilder(); string line; while ((line = reader.readline()) != null) sb.append(line + "\n"); string resstring = sb.tostring(); is.close(); log.d("http post response:", response.tostring()); log.d("http response:", resstring); } catch (exception e) { system.out.println("error: " + e); } return ""; } @override protected void onpostexecute(string msg) { log.d(upload_display_picture, "on post execute running"); super.onpostexecute(msg); uploadingimage.setmessage("registering user details..."); new registeruserdetails().execute(registrationdetails); } }.execute(null, null, null); }
Comments
Post a Comment