更改Android文件上传中的文件名

I want to change the name of a file, which is uploaded in an Android app, but I don't know how to.

A string in my android code should be the future file name. I've tested some stuff, but no success yet.

The code is implemented in an Async task (the upload itself is working).

    private int serverResponseCode;

public String upLoad2Server(String sourceFileUri) {
    String fileName = sourceFileUri;
    HttpURLConnection conn = null;
    DataOutputStream dos = null;
    String lineEnd = "
";
    String twoHyphens = "--";
    String boundary = "*****";
    int bytesRead, bytesAvailable, bufferSize;
    byte[] buffer;
    int maxBufferSize = 1 * 1024 * 1024;
    File sourceFile = new File(sourceFileUri);
    if (!sourceFile.isFile()) {
        Log.e("Huzza", "Source file does not exist");
        return null;
    }



    try {
        FileInputStream fileInputStream = new FileInputStream(sourceFile);
        URL url = new URL(Config.UPLOAD_URL);
        conn = (HttpURLConnection) url.openConnection();
        conn.setDoInput(true);
        conn.setDoOutput(true);
        conn.setUseCaches(false);
        conn.setRequestMethod("POST");

        String testName = "ThisCouldBeMyNewFileName";



        conn.setRequestProperty("Connection", "Keep-Alive");
        conn.setRequestProperty("ENCTYPE", "multipart/form-data");
        conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);

        conn.setRequestProperty("myFile", fileName);
        conn.setRequestProperty("myTest", testName);


        dos = new DataOutputStream(conn.getOutputStream());


        //I've been trying some stuff here...
        //OutputStream outputStream = conn.getOutputStream();
        //BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(dos, "UTF-8"));
        //String dataString = URLEncoder.encode("testName", "UTF-8") +"="+URLEncoder.encode(testName,"UTF-8");
        //bufferedWriter .write(dataString);
        //bufferedWriter.flush();
        //bufferedWriter.close();
        //Test end, no success with this one

        dos.writeBytes(twoHyphens + boundary + lineEnd);

        dos.writeBytes("Content-Disposition: form-data; name=\"myFile\";filename=\"" + fileName + "\"" + lineEnd);

        //Tried something like this too, but didn't work either.
        //dos.writeBytes("Content-Disposition: form-data; name=\"myTest\";filename=\"" + testName + "\"" + lineEnd);


        dos.writeBytes(lineEnd);

        bytesAvailable = fileInputStream.available();
        Log.i("Huzza", "Initial .available : " + bytesAvailable);

        bufferSize = Math.min(bytesAvailable, maxBufferSize);
        buffer = new byte[bufferSize];

        bytesRead = fileInputStream.read(buffer, 0,bufferSize);

        while (bytesRead > 0) {
            dos.write(buffer, 0, bufferSize);
            bytesAvailable = fileInputStream.available();
            bufferSize = Math.min(bytesAvailable, maxBufferSize);
            bytesRead = fileInputStream.read(buffer, 0, bufferSize);
        }

        dos.writeBytes(lineEnd);
        dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);

        serverResponseCode = conn.getResponseCode();

        fileInputStream.close();

        bufferedWriter .write(dataString);
        bufferedWriter.flush();


        dos.flush();
        dos.close();
        bufferedWriter.close();
    }

    catch (MalformedURLException ex) {
        ex.printStackTrace();
    }
    catch (Exception e) {
        e.printStackTrace();
    }

    if(serverResponseCode == 200) {
        StringBuilder sb = new StringBuilder();
        try{
            BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line;
            while((line = rd.readLine()) != null) {
                sb.append(line);
            }
            rd.close();
        }
        catch(IOException ioex) {

        }
        return sb.toString();
    }
    else {
        return "Could not upload";
    }
}

}

The PHP Part

if($_SERVER['REQUEST_METHOD']=='POST'){
$file_name = $_FILES['myFile']['name'];
$file_size = $_FILES['myFile']['size'];
$file_type = $_FILES['myFile']['type'];
$temp_name = $_FILES['myFile']['tmp_name'];

//Either this for the POST attempt
$test_name = $_POST['testName'];

//Or this one, then imagine the upper line not being there
$test_name = $_FILES['myTest']['testName'];


$ext = pathinfo($file_name, PATHINFO_EXTENSION);

$location = "files/";

move_uploaded_file($temp_name, $location . $test_name . "." . $ext);
echo "http://contender.hol.es/Contender/files/".$file_name;
}

Thanks in advance and have a good day everybody! :)