Android apache多部分php上传文件第6行中的未定义索引

Android apache多部分php上传文件第6行中的未定义索引,php,android,file-upload,multipartform-data,Php,Android,File Upload,Multipartform Data,我正在尝试实现文件上传模块 我已经用html测试了php服务器部分,它是正确的 <?php error_reporting(E_ALL); $target_path = "target/"; // $target_path = $target_path . basename( $_FILES['file']['name']); $name = $_FILES["file"]["name"]; echo $name."<br>"; $ex

我正在尝试实现文件上传模块

我已经用html测试了php服务器部分,它是正确的

<?php
error_reporting(E_ALL);

    $target_path  = "target/";
  //  $target_path = $target_path . basename( $_FILES['file']['name']);
    $name = $_FILES["file"]["name"];
    echo $name."<br>";
    $ext = end(explode(".", $name));
        echo $ext."<br>";
    $randname = random_string(30);
    echo $randname."<br>";
    $fname = $randname . "." .$ext;
    echo $fname."<br>";
    $target_path = $target_path .$fname;
    echo $target_path."<br>";
    if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
        //echo "The file ".  basename( $_FILES['file']['name'])." has been uploaded";
        //echo random_string(50);



        // $arr = array ('data'=>'http://gallicalab.com/target/'.$_FILES['file']['name']);
        $arr = array ('data'=>'http://gallicalab.com/target/'.$fname);

        echo json_encode($arr); // {"a":1,"b":2,"c":3,"d":4,"e":5}
    } 
    else {
        echo "There was an error uploading the file, please try again!";
    }



    function random_string($length) {
    $key = '';
    $keys = array_merge(range(0, 9), range('a', 'z'));

    for ($i = 0; $i < $length; $i++) {
        $key .= $keys[array_rand($keys)];
    }

    return $key;
    }

?>
}


并在文件第6行显示未定义索引

想想这里的问题$name=$\u FILES[“file”][“tmp\u name”];代码已修改,但问题仍然存在于$_文件[“file”]上的var_转储,并检查[“name”]是否存在我已使用html上载代码进行检查。[“名称”]存在。但当谈到使用ApacheHTTPMIME实体进行android上传时,它并不存在,请看一看
public String uploadRecording(File frecord ) throws FileNotFoundException {
    // TODO Auto-generated method stub
    String destinationPath = "http://www.gallicalab.com/upload.php";        

     System.out.println("step 3");
    String result = "";
    HttpClient client=new DefaultHttpClient();
    HttpPost post=new HttpPost(destinationPath);

 System.out.println("step 4");
try{
    //setup multipart entity
    MultipartEntity entity=new MultipartEntity();

        FileBody fileBody=new FileBody(frecord);
         System.out.println("step 5");
        entity.addPart("file", fileBody);



    post.setEntity(entity);


     System.out.println("step 5.5");
    HttpResponse uploadReponse = client.execute(post);
    Log.d("debug" , "Response : " + uploadReponse);
    Log.d("debug" , "Response 2: " + uploadReponse.getStatusLine().getReasonPhrase());
    Log.d("debug" , "Response 3: " + uploadReponse.getStatusLine().getStatusCode());

     System.out.println("step 6");
    if(uploadReponse.getStatusLine().getStatusCode() == 200){
        InputStream isInputStream = uploadReponse.getEntity().getContent();
        BufferedReader reader = new BufferedReader(new InputStreamReader(    isInputStream, "utf-8"), 8192);
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) {
            sb.append(line);
        }

        result =   sb.toString();  
    }
}catch(Exception e){
    e.printStackTrace();
}     
return result;