![](/img/trans.png)
[英]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.