Jump to content

list files in a directory script error

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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...