视频未从android上传到服务器

视频未从android上传到服务器,android,video,Android,Video,我想将视频从android上传到php服务器。视频只上传一部手机。如果我从另一部手机上传视频,意味着视频不上传。如何从所有手机上传视频 这是我的代码 class UploadTask extends AsyncTask<String, Void, String> { String sResponse = null; @Override protected void onPreExecute() { // TODO Auto-generat

我想将视频从android上传到php服务器。视频只上传一部手机。如果我从另一部手机上传视频,意味着视频不上传。如何从所有手机上传视频 这是我的代码

 class UploadTask extends AsyncTask<String, Void, String> {

    String sResponse = null;

    @Override
    protected void onPreExecute() {
        // TODO Auto-generated method stub
        super.onPreExecute();
        pd.setMessage("loading");
        pd.show();
    }



    @Override
    protected String doInBackground(String... params) {
        try {

            String url =Serviceurl.url + "video";

            HttpClient httpClient = new DefaultHttpClient();
            HttpContext localContext = new BasicHttpContext();
            HttpPost httpPost = new HttpPost(url);


            MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
            int i=0;

            File sourceFile = new File(selectedPath);

            entity.addPart("video", new FileBody(sourceFile));
            entity.addPart("user_id", new StringBody("66"));


            httpPost.setEntity(entity);


            ByteArrayOutputStream bytes = new ByteArrayOutputStream();

            entity.writeTo(bytes);

            String content = bytes.toString();
            String content1 = entity.toString();
            Log.e("MultiPartEntityRequest:",content);
            Log.e("MultiPartEntity---11:",content1);
            HttpResponse response = httpClient.execute(httpPost,
                    localContext);
            sResponse = EntityUtils.getContentCharSet(response.getEntity());

            System.out.println("sResponse : " + sResponse);




        } catch (Exception e) {

            Log.e(e.getClass().getName(), e.getMessage(), e);

        }
        return sResponse;
    }

    @Override
    protected void onPostExecute(String sResponse) {
        try {


            pd.dismiss();

        } catch (Exception e) {
            Toast.makeText(getApplicationContext(), e.getMessage(),
                    Toast.LENGTH_LONG).show();
            Log.e(e.getClass().getName(), e.getMessage(), e);
        }

    }
}
class UploadTask扩展了AsyncTask{
字符串sResponse=null;
@凌驾
受保护的void onPreExecute(){
//TODO自动生成的方法存根
super.onPreExecute();
pd.setMessage(“加载”);
pd.show();
}
@凌驾
受保护的字符串doInBackground(字符串…参数){
试一试{
字符串url=Serviceurl.url+“视频”;
HttpClient HttpClient=新的DefaultHttpClient();
HttpContext localContext=新的BasicHttpContext();
HttpPost HttpPost=新的HttpPost(url);
MultipartEntity=新的MultipartEntity(HttpMultipartMode.BROWSER_兼容);
int i=0;
文件源文件=新文件(selectedPath);
entity.addPart(“视频”,新文件体(sourceFile));
entity.addPart(“用户id”,新的StringBody(“66”);
httpPost.setEntity(实体);
ByteArrayOutputStream字节=新建ByteArrayOutputStream();
实体写入(字节);
字符串内容=字节。toString();
字符串content1=entity.toString();
Log.e(“多方请求:”,内容);
Log.e(“多方当事人--11:”,内容1);
HttpResponse response=httpClient.execute(httpPost,
本地上下文);
sResponse=EntityUtils.getContentCharSet(response.getEntity());
System.out.println(“响应:+sResponse”);
}捕获(例外e){
Log.e(e.getClass().getName(),e.getMessage(),e);
}
返回响应;
}
@凌驾
PostExecute上受保护的void(字符串响应){
试一试{
pd.解散();
}捕获(例外e){
Toast.makeText(getApplicationContext(),e.getMessage(),
Toast.LENGTH_LONG).show();
Log.e(e.getClass().getName(),e.getMessage(),e);
}
}
}

所以您有例外。请告诉他们。准确地说出发生了什么,什么没有发生,什么发生了。你为什么不告诉我你得到了什么样的回应?所以你有例外。请告诉他们。准确地说出发生了什么,什么没有发生,什么发生了。你为什么不告诉我你得到了什么样的答复?