使用HTTP URL将文件名从Java传递到PHP

使用HTTP URL将文件名从Java传递到PHP,java,php,Java,Php,我想使用SFTP从Java上传文件,并使用PHP脚本上传文件路径,但问题是我没有在PHP脚本中获得路径,比如在文本框中,但在IDE中显示了路径 使用SFTP直接上传是可以的,但是文件的路径没有显示在我的PHP文本框中* JAVA代码 BufferedReader in; boolean blResult = sftpBean.connect("xx.xxx.xx.x", xx, "xxxx", "xxxx"); if (blResult) { System.out.println("Su

我想使用SFTP从Java上传文件,并使用PHP脚本上传文件路径,但问题是我没有在PHP脚本中获得路径,比如在文本框中,但在IDE中显示了路径

使用SFTP直接上传是可以的,但是文件的路径没有显示在我的PHP文本框中*

JAVA代码

BufferedReader in;
boolean blResult = sftpBean.connect("xx.xxx.xx.x", xx, "xxxx", "xxxx");
if (blResult) {
    System.out.println("Successfull Connection");
    String path="/home/folder/upload/";
    String p="http://xx.xxx.xx.x/upload/";
    blResult = sftpBean.uploadFile(data,result,path);           
    if(blResult) {
        OutputStream os = null;
        InputStream is = null;
        URL url = new URL("http://xx.xxx.xx.x/folder/test.php?test="+p+result); 
        URLConnection conn = url.openConnection();
        conn.connect();                          
        in = new BufferedReader(newInputStreamReader(conn.getInputStream())); 
        String inputLine;         
        while((inputLine = in.readLine()) != null) {
            System.out.println(inputLine);
        }
        in.close();
PHP代码test.PHP

您应该输入查询参数

String testParameterEncoded = URLEncoder.encode(p + result, StandardCharsets.UTF_8);
URL url = new URL("http://xx.xxx.xx.x/folder/test.php?test=" + testParameterEncoded);

IDE结果回显“”什么是
结果
String testParameterEncoded = URLEncoder.encode(p + result, StandardCharsets.UTF_8);
URL url = new URL("http://xx.xxx.xx.x/folder/test.php?test=" + testParameterEncoded);