【问题标题】:Non-English Windows directory name in url linkurl 链接中的非英文 Windows 目录名称
【发布时间】:2013-10-07 13:41:36
【问题描述】:

我有一个搜索计算机 windows 目录的 php 文件。如果我有一个包含非英语字符(如“Önder Şoğlopıpk”)的目录,它将返回 null。 我的php文件是这样的:

$port = $_GET["port"];//Here is computer's port
$path = trim($_GET["path"]);//Here is the path which does not work
$path = str_replace(" ","+",$path);
$path = urlencode($path);
$suffix = $_GET["suffix"];//Here is suffix which I am searching
if($_GET){ 
$url='http://mylink.com?host=localhost&port='.$port.'&showerrorinxml=yes&link=proc_list?find_files___path='.$path.'___suffix='.$suffix.'';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($data);

如果路径变量中有一个非英文字符,例如“Ş Ğ ı ş ğ I”,它将返回 null 给我。如果是英文就没有问题。我可以搜索我想要的。 我正在对其进行urlencoding,但它没有用。 我的网址似乎是一个名为“Seçpa Yazılım Login”的目录:

http://mylink.com?host=localhost&port=44833&showerrorinxml=yes&link=proc_list?find_files___path=D%3A%2FSe%C3%A7pa%2BYaz%C4%B1l%C4%B1m%2BLogin%2F___suffix=.css

它似乎在浏览器上是这样的:

http://mylink.com?host=localhost&port=44833&showerrorinxml=yes&link=proc_list?find_files___path=D%3A%2FSeçpa%2BYazılım%2BLogin%2F___suffix=.css

有人对这个话题有想法吗?

【问题讨论】:

    标签: php windows directory filenames


    【解决方案1】:

    检索到输入后需要urldecode

    $path = trim( urldecode( $_GET['path'] ) );
    

    更新:好的,请仔细阅读您的问题。对我来说,好像您对 URL 进行了两次编码。第一次是通过 HTTP 请求从浏览器发送隐式发送,第二次在$path = urlencode( $path );

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-07
      • 2021-08-27
      • 2011-06-09
      • 1970-01-01
      • 1970-01-01
      • 2017-05-06
      相关资源
      最近更新 更多