Android Video Upload to Php server? -
how upload video or image file php server.anyone provide sample app or source upload file in php server please.
i'd suggest creating asynctask handle upload , use apache libs post server. have system in place posts images linux server , php accepts post , saves image data. try this, you'll need commons-io jar , httpmime jar apache if remember correctly.
import org.apache.http.httpresponse; import org.apache.http.client.httpclient; import org.apache.http.client.methods.httppost; import org.apache.http.entity.mime.multipartentity; import org.apache.http.entity.mime.content.inputstreambody; import org.apache.http.entity.mime.content.stringbody; import org.apache.http.impl.client.defaulthttpclient; httpclient httpclient = new defaulthttpclient(); httppost postrequest = new httppost("http://www.mywebserver.com/upload"); multipartentity multipart = new multipartentity(); multipart.addpart("photo",bitmapdata); postrequest.setentity(multipart); httpresponse response = httpclient.execute(postrequest); inputstream content = response.getentity().getcontent(); bufferedreader reader = new bufferedreader(new inputstreamreader(content)); stringbuilder servermsg = new stringbuilder(); string line = ""; while((line = reader.readline()) != null){ servermsg.append(line + "\n"); } content.close();
then on in php, check post , save image using whatever library or code prefer. i'm sure adjust code send video data instead of photo.
Comments
Post a Comment