Questions tagged [scandir]

List files and directories inside the specified path

PHP usage:

array scandir ( string $directory [, int $sorting_order = SCANDIR_SORT_ASCENDING [, resource $context ]] )

Returns an array of filenames on success, or FALSE on failure. If directory is not a directory, then boolean FALSE is returned, and an error of level E_WARNING is generated.

354 questions
-1
votes
1 answer

Scandir For Directories Above

have a website that is obviously in the root of my server. I am now making a web app, which lies in m/iphone/. All was going well but my website uses scandir() with all of the files in a folder on the root of my server. How can I access these files…
-1
votes
3 answers

Warning: opendir(): The system cannot find the file specified. (code: 2)

I'm trying to turn the files in my 'objects' directory into an array, then use them to load the objects. But, for some reason, I continue to get this error Warning: opendir(C:\xampp\htdocs/objects,C:\xampp\htdocs/objects): The system cannot find…
user3656876
  • 1
  • 1
  • 2
-2
votes
2 answers

PHP: List all files in a folder recursively and fast

I am looking for the fastest way to scan a directory recursively for all existing files and folders. Example: - images -- image1.png -- image2.png -- thumbnails --- thumb1.png --- thumb2.png - documents -- test.pdf Should…
SPQRInc
  • 162
  • 4
  • 23
  • 64
-2
votes
1 answer

c - scandir, memory fault core dumped error

I am trying to list information about files in a specified directory but I am getting a Memory Fault Core Dumped error. List Directory Method: int listdir(char *path) { struct dirent **dirlist; int n; char *fullpath; n = scandir(path, &dirlist,…
-2
votes
2 answers

PHP scandir doesn't work

I have seen another question with the same problem, but with just 1 answer, which didn't worked for me. The question: PHP scandir - multiple directories I'm using Joomla! to create my site (I create everything with templates, most that I don't…
user5147563
-2
votes
3 answers

Count array elements returned by scandir(); PHP

I have in folder "files" some folders. I want to return the count of this folders by my php code: $x = count(scandir('/files')); echo $x; But this is not working. What is wrong?
Artimal
  • 651
  • 7
  • 24
-2
votes
3 answers

How do I use scandir (or another method) to sort the directory results alphabetically?

Not skilled with PHP at all. I used old code from another site (that I did not write) to create a CMS for a client. Problem is, the directory results here are not returned alphabetically. I have read that scandir will do that, whereas readdir will…
-3
votes
4 answers

PHP: Undefined offset while using explode a scandir

i'm trying to explode file names of a directory. but i got a error.
Jasjeet Singh
  • 23
  • 1
  • 1
  • 5
-5
votes
1 answer

How do I skip files which I don't have permission to read/access when using scandir(), to avoid all the logged errors?

I use scandir() to search through dirs on the computer. I have also tried DirectoyIterator with the exact same result (it appears to use scandir() internally). Some sub-dirs apparently have special permissions, for they pollute my error log with…
1 2 3
23
24