I want to send a text file from a java class to php and store it on the server.
But the file never gets there

this is my java code:

```
public class JavaUrlConnectionReader
{
    public static void main(String[] args) throws Exception {

        HttpURLConnection httpUrlConnection = (HttpURLConnection) new URL("http://URL/upload.php").openConnection();
        httpUrlConnection.setDoOutput(true);
        httpUrlConnection.setRequestMethod("POST");

        File myFile = new File ("/path_to_file/test.txt");
        byte [] mybytearray  = new byte [(int)myFile.length()];
        FileInputStream fis = new FileInputStream(myFile);
        OutputStream os = httpUrlConnection.getOutputStream();
        BufferedInputStream bis= new BufferedInputStream(fis);
        bis.read(mybytearray,0,mybytearray.length);

        System.out.println("Sending the file of size:"+ mybytearray.length + " bytes");

        os.write(mybytearray,0,mybytearray.length);

        System.out.println("File sent.");
        BufferedReader in = new BufferedReader(new InputStreamReader(httpUrlConnection.getInputStream()));

        String s = null;
        while ((s = in.readLine()) != null) {
            System.out.println(s);
        }
        os.flush();
        bis.close();
        os.close();
        fis.close();
        in.close();
     }
}

```

and this is the php script

```
    <?php 

$target_path = "../output/"; 

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { 
    echo "The file ". basename( $_FILES['uploadedfile']['name'])." has been uploaded"; 
} 
else{ 
    echo "There was an error uploading the file, please try again!"; 
}

?> 

```

It seems the text file never gets there.
I think the java code should be ok. I am doing something wrong in the php file.
Any help what's wrong with the php file?