tags:

views:

198

answers:

4
+4  A: 
"/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.

SilentGhost
Or you could use "./jobops/*.txt"
Yacoby
In addition to this, make sure that the user in which php is running under does has access to that folder
Scott
while I don't know about actual OP's system, on error `glob` on majority of OSs will return `false`.
SilentGhost
that worked i usually do C# programing so i know what i want just some little tweaks here and there to get it to workthanks again for the help +1
Crash893
+1  A: 

maybe something like:

$files = glob($_SERVER['DOCUMENT_ROOT']."/jobops/*.txt");
John Boker
from the glob docs: *The pattern. No tilde expansion or parameter substitution is done. *
SilentGhost
Negative Ghost rider ~ does not work
Crash893
modified the answer
John Boker
+1  A: 

If you are running this from a web server? Could it be the User and Group settings of the web server will not allow access to other directories? Is this a permissions issue? Check the web server's error_log and access_logs for clues.

Scott Lundberg
+2  A: 

As said

"/jobops/*.txt"

is an absolute path since it starts with a "/" (slash)

Relative paths are those not starting with a slash, so

"jobops/*.txt"

"./jobops/*.txt"

"../jobops/*.txt"

are all relative ... the point is: relative to what?

On OSs it is relative to the directories enumerated in the environment variable PATH (and often the current working dir is the first one listed into this variable, leding to the erroneous guess that "jobops/*.txt" is referred to the jabops dir in the current dir!)

In PHP, that is you environment, it is better to always use absolute paths, which does not implies to hard code them of course.

I suggest to do the following:

dirname(__FILE__).'/jobops/*.txt'

which is how to use paths in PHP, correctly

AlberT