0

I have been banging my head for a couple of days, browsing the internet for some answer but so far nothing... I am working on an android app which I need it to upload a video to a php server. I tested with image and audio, both work but the video I can not get it working... It seems like it is passing nothing, here is the code (I am using apache). The variables declarations:

public static File mediaStorage = new File(
        Environment
                .getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM),
        "Camera");
public static File video = new File(mediaStorage.getPath() + File.separator
        + "20131103_105102.mp4");
String ture = video.toString();

now the method:

public void uploadFile() {

    HttpClient client = new DefaultHttpClient();
    HttpPost post = new HttpPost("http://server");
    MultipartEntity reqEntity = new MultipartEntity();
    reqEntity.addPart("uploaded_file", new FileBody(video));


    post.setEntity(reqEntity);

    try {
        HttpResponse response = client.execute(post);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    dialog.dismiss();
       } 

not doing anything, now if I put an image path or an audio path, everything works well... What am I doing wrong?

Jayo2k
  • 251
  • 3
  • 14
  • Can you please be more precise with that? What "do anything" means exactly? No content sent to the server? Any stacktrace on the mobile app? – Alfredo Cavalcanti Nov 10 '13 at 20:38
  • I mean, if I put image path as string or audio file, the file get uploaded, but with the video file, seems like it is passing a blank data. It is like nothing is sent, I tested and with audio and picture, I see on the database the uploaded file and the name, but with the video, I see nothing – Jayo2k Nov 10 '13 at 21:04
  • May [this answer](http://stackoverflow.com/a/2937140/845443) help you out? – Alfredo Cavalcanti Nov 10 '13 at 21:28
  • thanks but after doing more experimentations, it turned out the code had nothing wrong, appache can not send large file... I managed to send a 9mb video, but 30mb is too heavy – Jayo2k Nov 11 '13 at 14:31
  • Now you can answer you own question. :-) – Alfredo Cavalcanti Nov 11 '13 at 14:38

2 Answers2

2

After experimenting, it turned out the code has nothing wrong, just that large file can not be uploaded with apache, in fact uploading large file in Android is a big task

Jayo2k
  • 251
  • 3
  • 14
1

Still learning how to send data over php; hope these tutorial help. They send data to the server, I guess similar logic could be applied to video also.

http://codeoncloud.blogspot.in/2013/07/android-mysql-php-json-tutorial.html

http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/

Zen
  • 2,698
  • 4
  • 28
  • 41