Android - Uploading Image that sits at the public folders -
i'm trying upload image not sits under app folder @ public folder.
in order upload image, i'm using next code -
private string dopicupload(string path1){ file file1 = new file(path1); string urlstring = "http://87.182.1.15/upload_pic.php"; try { httpclient client = new defaulthttpclient(); httppost post = new httppost(urlstring); filebody bin1 = new filebody(file1); multipartentity reqentity = new multipartentity(); reqentity.addpart("uploadedfile1", bin1); post.setentity(reqentity); httpresponse response = client.execute(post); resentity = response.getentity(); final string response_str = entityutils.tostring(resentity); return response_str; } catch (exception ex){ log.e("debug", "error: " + ex.getmessage(), ex); string expction = "0"; return expction; } }
now, when debug code seems stops @ line -
httpresponse response = client.execute(post);
and logcat says -
03-21 14:13:16.074: e/debug(26180): error: /file:/storage/emulated/0/mydir/img_1395403976349.jpg: open failed: enoent (no such file or directory) 03-21 14:13:16.074: e/debug(26180): java.io.filenotfoundexception: /file:/storage/emulated/0/mydir/img_1395403976349.jpg: open failed: enoent (no such file or directory)
now can see path of image fine, there's file on device same name.
so doing wrong here? should refer media environment, , if should do?
thanks kind of help
add following manifest file*
<uses-permission android:name="android.permission.write_external_storage" />
and try use environment.getexternalstoragedirectory()
file path.
path should /storage/emulated/0/mydir/img_1395403976349.jpg
Comments
Post a Comment