java - File upload HttpClient -- no file in selected folder -
i'm using loopj/android-async-http lib upload files in server.
my android code:
file myfile = new file(getrealpathfromuri(settintsactiviy.this, selectedimage)); requestparams params = new requestparams(); try { params.put("uploaded_file", myfile); params.put("name", "adfadfa"); params.put("tmp_name", "fadfadfa"); } catch (filenotfoundexception e) { e.printstacktrace(); } asynchttpclient client = new asynchttpclient(); client.post("http://localhost:8081/html/upload.php", params, new asynchttpresponsehandler() { @override public void onsuccess(int statuscode, header[] headers, byte[] responsebody) { system.out.println("statuscode "+statuscode);//statuscode 200 } @override public void onfailure(int statuscode, header[] headers, byte[] responsebody, throwable error) { } });
my upload.php
<?php $file_path = "/images/"; $file_path = $file_path . basename( $_files['uploaded_file']['name']); if(move_uploaded_file($_files['uploaded_file']['tmp_name'], $file_path)) { echo "success"; } else{ echo "fail"; }?>
log android result:
06-09 22:19:53.192 18958-18958/br.md.screamchat v/asynchttprh: progress 205268 221141 (93%) 06-09 22:19:53.192 18958-18958/br.md.screamchat v/asynchttprh: progress 209364 221141 (95%) 06-09 22:19:53.192 18958-18958/br.md.screamchat v/asynchttprh: progress 213460 221141 (97%) 06-09 22:19:53.192 18958-18958/br.md.screamchat v/asynchttprh: progress 217556 221141 (98%) 06-09 22:19:53.192 18958-18958/br.md.screamchat v/asynchttprh: progress 221103 221141 (100%) 06-09 22:19:53.193 18958-18958/br.md.screamchat v/asynchttprh: progress 221105 221141 (100%) 06-09 22:19:53.193 18958-18958/br.md.screamchat v/asynchttprh: progress 221141 221141 (100%) 06-09 22:19:56.252 18958-18958/br.md.screamchat v/asynchttprh: progress 7 7 (100%) 06-09 22:19:56.252 18958-18958/br.md.screamchat i/system.out: statuscode 200
but when open selected folder not have file.
Comments
Post a Comment