douzong2206 2009-09-02 15:17
浏览 23
已采纳

php不扫描文件的相对路径

Here is my current code (that i am very proud of for my first attempt at php)

<?php
$files = glob("/jobops/*.txt");
$indexcount = count($files);
sort($files);
print("<br>"+$indexcount+"<br>");
foreach ($files as &$file)
{
    print("<a href=\"$file\">$file</a><br>");
}
?>

the problem is glob again works fine in the root directory (where this script is located) but when i point it to a specific folder it returns 0 files found.

I've included a screen grab from my ftp client showing the directory structure (below)

so I'm confused what I'm doing wrong on the glob

www.markonsolutions.com/test.php is where the script is and if you click it will return 0 files found

alt text

  • 写回答

4条回答 默认 最新

  • dtslobe4694 2009-09-02 15:19
    关注
    "/jobops/*.txt"
    

    is an absolute path on *nix, if you want to point to the directory that is in the same directory as a your php script you need to use:

    "jobops/*.txt"
    

    which is a relative path.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染