Questions tagged [readdir]

The C, Perl or PHP library function for reading from an open directory.

The readdir C library function reads and returns the next entry, as a struct dirent *, from an open DIR *. You should open the directory using opendir first. This can also refer to the Perl or PHP functions with the same purpose.

Links:

301 questions
0
votes
1 answer

Random order of readdir

How would I modify my PHP code below to output all the files in the directory, but to put them in a random order that changes each time the page gets reloaded? if ($handle = opendir("files/slideshow/")) { while (false !== ($slide =…
Kody
  • 752
  • 2
  • 11
  • 22
0
votes
3 answers

Perl - A way to get only the first (.txt) filename from another directory without loading them all?

I have a directory that holds ~5000 2,400 sized .txt files. I just want one filename from that directory; order does not matter. The file will be processed and deleted. This is not the scripts working directory. The intention is: to open that…
0
votes
1 answer

PHP readdir, glob and exec('ls') return in an empty array for some directories under Apache

I have developed the following PHP code in order to read a specific directory called /dados/capture: tst2.php \n"; exec('ls /dados/capture/',$base); echo "/dados/capture content…
Mauricio
  • 1
  • 1
0
votes
1 answer

Easy way to sort getting images from a gallery using php?

Hello there good people of stackoverflow. I have this code that basically get any photo i place in a folder called "pictures" and displays them on my page. Which is all good, and it works, with lightbox as well. My main question is, can there be an…
Sean Kerwin
  • 89
  • 1
  • 1
  • 9
0
votes
4 answers

calling opendir and readdir is changing my char array

This is the code i have so far, it finds where the root is fine, but when i add the line: printf(" name: %s\n", readdir(opendir(cur_spot))->d_name); it changes cur_spot and adds weird characters to it (filename: .~?) is what it prints.. any…
Troy Cosentino
  • 4,658
  • 9
  • 37
  • 59
0
votes
3 answers

get image files from directory on server for further processing

I have folders on the server that contain image files. I'm trying to get those files and then upload them further, but I think I'm using the wrong function. My code: $dir = "../uploads/".$folderimage."/"; if ($handle = opendir($dir)) { while…
Jjames
  • 183
  • 1
  • 3
  • 14
0
votes
1 answer

Howto send data through socket: one buffer, scatter/gatter or readdir like?

I'm writing an FUSE overlay fs (notifyfs), which can be an database clients can get data from through queries. My intention is to make it a cache/overlayfs/database clients can get data from when showing entries and their properties (attributes but…
user1388973
  • 119
  • 1
  • 11
0
votes
2 answers

Listing files in Directory in Ubuntu

I am trying to list files in the parent directory of the current directory, but when I try to execute this program from terminal I get Segmentation Error.. What am I doing wrong? Here is the code: #include #include #include…
Naruto
  • 1,710
  • 7
  • 28
  • 39
0
votes
3 answers

List all images in a directory not listing contents

I am using the following to list all of the jpg images in a directory, for some reason its not working though, I think some of my 's and .s may be in the wrong place, I think I have confused myself a bit :-S .
Iain Simpson
  • 8,011
  • 13
  • 47
  • 66
0
votes
5 answers

Ordering output when using readdir()

I'm fairly new to PHP and have been using PHP's readdir() to look into a folder full of images and render them out dynamically based on how many images there are in that folder. Everything works great, but one thing I've noticed is that the images…
user1563944
  • 403
  • 7
  • 18
0
votes
1 answer

Scandir Array display without file extensions

I'm using the following to create a list of my files in the 'html/' and link path. When I view the array it shows, for example, my_file_name.php How do I make it so the array only shows the filename and not the extension? $path =…
0
votes
1 answer

how to find a file in a directory based on a known id in php?

i have some images in a folder on a server: /9_123456.jpg /10_123457.jpg /21_123458.jpg /14_123459.jpg ... also i have a database that holds those file names. id file 9 9_123456.jpg 10 10_123457.jpg 21 21_123458.jpg 14 …
Patrioticcow
  • 26,422
  • 75
  • 217
  • 337
0
votes
4 answers

Why is $count not updating?

$dir_handle = @opendir($url) or die("Unable to open $url"); $count = "0"; while ($file = readdir($dir_handle)) { if (!is_dir($url.'/'.$file) && ($file="*.jpg" || $file="*.gif" || $file="*.png") && $file!="picture0.*") { …
imHavoc
  • 277
  • 3
  • 15
0
votes
1 answer

For readdir_r, may entry and result have the same value?

Can I use readdir_r like this? I don't find anything about it in the spec, but maybe I'm just blind... readdir_r(dir, entry, &entry);
thejh
  • 44,854
  • 16
  • 96
  • 107
0
votes
2 answers

creating photo gallery without database

I am creating photo gallery using readdir , in that directory there are non image file also . There are several thousands files in the directory , i am really struggling to filter the extension . Any help will be appreciated if ($handle =…
user1401498