2011-02-17 3 views
0

안녕하세요 여러분, 다음 코드를 사용하고 있지만 error0가 응답으로 표시됩니다. 성공하려면 다음 코드를 따르십시오.Android에서 PHP SERver로 비디오를 업로드하는 방법

public void video() 
{ 
    File file = new File(exsistingFileName); 
    try { 
     HttpClient client = new DefaultHttpClient(); 
     String postURL = "http://10.0.0.27/sportscloud/devices/uploadBlogData.php"; 
     HttpPost post = new HttpPost(postURL); 
     FileBody bin = new FileBody(file); 
     MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); 

     reqEntity.addPart("email", new StringBody("[email protected]", "text/plain", Charset.forName("UTF-8"))); 
     reqEntity.addPart("gameId", new StringBody("1024", "text/plain", Charset.forName("UTF-8"))); 
     reqEntity.addPart("source", new StringBody("phone", "text/plain", Charset.forName("UTF-8"))); 
     reqEntity.addPart("uploadfile",bin); 
     post.setEntity(reqEntity); 
     HttpResponse response = client.execute(post);  

     HttpEntity resEntity = response.getEntity(); 
     if (resEntity != null) {  
        Log.i("RESPONSE",EntityUtils.toString(resEntity)); 
     } 

    } catch (Exception e) { 
     e.printStackTrace(); 
    } 

}

답변

0

당신이 오류의 종류를받을 수 있나요? :)

InputStream is = this.getAssets().open(exsistingFileName); 
byte[] data = IOUtils.toByteArray(is); 
InputStreamBody isb = new InputStreamBody(new ByteArrayInputStream(data),"uploadedFile"); 
reqEntity.addPart("uploadfile",isb); 


좋은 운을 시험해 대한 추가 정보는 도움이 될 것입니다

관련 문제