0

I am developing Android app in which i upload large video from android to php server and i done this task which run perfect on emulator but when i checked on mobile it doesn't give any error but video is not upload on server
please give me any suggestion as soon as possible because it is very urgent for me.
My code is:

public void up1()
    {
        String url ="http://myservername/photoshare/uploads.php?imgname=" + jm +"&uid="+ uid +"&albumnm=" + albumname;
          Log.d("in fun", "Function");

        HttpParams httpParameters = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpParameters,30000);

        HttpConnectionParams.setSoTimeout(httpParameters,6000);
        HttpConnectionParams.setTcpNoDelay(httpParameters, true);

         HttpClient client = new DefaultHttpClient(httpParameters);

       // HttpClient client = new DefaultHttpClient();
        HttpPost post = new HttpPost(url);
        MultipartEntity mpEntity = new MultipartEntity();
        //Path of the file to be uploaded
        String filepath = selectedImagePath;
        File file = new File(filepath);
        ContentBody cbFile = new FileBody(file, "video/mp4");         

        mpEntity.addPart("uploadedfile", cbFile);

        try {
               mpEntity.addPart("name", new StringBody("Test", Charset.forName("UTF-8")));
               mpEntity.addPart("data", new StringBody("This is test report", Charset.forName("UTF-8")));
               post.setEntity(mpEntity);
                //Execute the post request
                HttpResponse response1 = client.execute(post);

                //Get the response from the server
                HttpEntity resEntity = response1.getEntity();
                String Response=EntityUtils.toString(resEntity);

                Log.d("Response:", Response);
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

Thank you in advance..

Edited by n5555

2
Contributors
2
Replies
5
Views
4 Years
Discussion Span
Last Post by n5555
0

when i connect mobile with logcat and see error 408:Request TimeOut.How to solve?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.