Android : Upload large files using MultipartEntity

前端 未结 1 1256
再見小時候
再見小時候 2021-01-14 18:39

According this answer \"Android upload video to remote server using HTTP multipart form data\" I do all steps.

But I don\'t know how I code for server side! I mean a

相关标签:
1条回答
  • 2021-01-14 19:13

    This code worked properly and PHP code I should use is as simple as this:

    <?php
    
        $file_path = "uploads/";
    
        $file_path = $file_path . basename( $_FILES['videoFile']['name']);
        if(move_uploaded_file($_FILES['videoFile']['tmp_name'], $file_path)) {
            echo "success";
        } else{
            echo "upload_fail_php_file";
        }
     ?>
    

    NOTE that videoFile must match exactly with

    reqEntity.addPart("videoFile", filebodyVideo);

    And the MOST Important problem you probably face to, is default value of post_max_size and upload_max_filesize in the server config! As default is too small and when you try to upload large files, the PHP script return : "upload_fail_php_file" with no error or exception throwing. So remember to set these values as big as enough...

    Enjoy coding.

    0 讨论(0)
提交回复
热议问题