[英]Java - Get filename from “http://www.example.com/something.php?id=1111”
[英]Passing filename from Java to PHP using HTTP URL
我想使用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
<?php
$path=$_GET['test'];
echo "<input type='text' value='$path'>";
?>
预期的结果是路径名将显示在我的php文本框中,到目前为止,结果仅显示在我的IDE中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.