php不会扫描文件的相对路径 [英] php doesn't scan relative path for files

查看:50
本文介绍了php不会扫描文件的相对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我当前的代码(我为第一次尝试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>");
}
?>

问题是glob在根目录(此脚本所在的位置)中再次可以正常工作,但是当我将其指向特定文件夹时,它会返回找到的0个文件.

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.

我已经从ftp客户端上抓取了一个屏幕截图,其中显示了目录结构(如下)

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 是脚本所在的位置,如果您点击它将返回找到的0个文件

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

推荐答案

"/jobops/*.txt"

* nix上的绝对路径,如果您要指向与您的php脚本位于同一目录中的目录,则需要使用:

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"

这是相对路径.

这篇关于php不会扫描文件的相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆