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.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")));
                //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
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
        } catch (IOException e) {
            // TODO Auto-generated catch block


Thank you in advance..

Recommended Answers

All 2 Replies

For start replace all the stack trace calls with Log.e() to get hold of exceptions

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.