php - How to send more than one image to server -
my code working 1 image when upload more 1 image show error me .
can me in getting out problem?
using below code able upload single image , want upload more 1 image please how can upload images. thanks
here code
string image_path=imageurl1; getdata(myfiles); } }); } public void getdata(string myfiles) { string image_retrive_url="http://tradewale.com/open/tradedata.php?submittype=postad"; pdialog = new progressdialog(postaddactivity.this); pdialog.setmessage(" sending..."); pdialog.setindeterminate(false); pdialog.setcancelable(false); pdialog.show(); bitmap bitmap = bitmapfactory.decodefile(myfiles); bytearrayoutputstream stream = new bytearrayoutputstream(); bitmap.compress(bitmap.compressformat.jpeg, 30, stream); byte [] byte_arr = stream.tobytearray(); string image_str = base64.encodebytes(byte_arr); final arraylist<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(); string title = title.gettext().tostring(); string description = description.gettext().tostring().trim(); string phonenumber = phonenumber.gettext().tostring(); string email = email.gettext().tostring(); string price = price.gettext().tostring(); namevaluepairs.add(new basicnamevaluepair("image",image_str)); namevaluepairs.add(new basicnamevaluepair("photo_url", image_retrive_url)); thread t = new thread(new runnable() { @override public void run() { try{ httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://tradewale.com/open/tradedata.php?submittype=postad"); httppost.setentity(new urlencodedformentity(namevaluepairs)); httpresponse response = httpclient.execute(httppost); final string the_string_response = convertresponsetostring(response); } catch(final exception e) { runonuithread(new runnable() { @override public void run() { toast.maketext(postaddactivity.this, "error " + e.getmessage(), toast.length_long).show(); } }); system.out.println("error in http connection "+e.tostring()); } } }); t.start(); }
to send more image in webservice. have change in webservice
also. add one more
parameter in service part. can able send more 1 image in 1 time.
and base64
string of second image e.g. img_str2
like :
string image_str = base64.encodebytes(byte_arr); string image_str2 = base64.encodebytes(byte_arr2);
and named new parameter in service image2
namevaluepairs.add(new basicnamevaluepair("image",image_str)); namevaluepairs.add(new basicnamevaluepair("image2",image_str2));
here image
, image2
2 diff
. parameter images. these parameter names must have define in service side code
.. service code can save iamges.
Comments
Post a Comment