Jump to content

list files in a directory script error


paulonline2501
 Share

Recommended Posts

hi everyone,

 

 

i've got a script that works on one website, that lists files in a directory.

 

ive moved the script to another website but now the script isnt working.

 

the script:

<ul><?php	foreach (glob('../../_docs/*.*') as $file){		  $file = basename($file);	  if ($file != 'index.php') 	  {?>		<li><?php echo"$file"?> <a href="../../_docs/<?php echo"$file"?>" target="_blank">[View]</a> 									<a href="../products/delete/?id=<?php echo"$file"?>">[Delete]</a></br>									URL: http://xxxxxxxx.com/CYC/_docs/<?php echo"$file"?>									</li>	  <?php 	  }	  		} ?></ul>

the error:

 

  • Warning: Invalid argument supplied for foreach() in/xxxxxxx/documents/index.php on line 188 [this refers to the line with the foreach glob in it]

Edited by as_bold_as_love
Link to comment
Share on other sites

Goodness, you should try to understand what things mean rather than waiting for other people to tell you. The PHP manual page for glob() would explain it, of course.

 

Returns an array containing the matched files/directories, an empty array if no file matched or FALSE on error.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...