# Looking for php code to read information from a file folder

**URL:** <https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040>\
**Category:** Uncategorized\
**Created:** [February 21, 2003, 9:08am UTC](https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040 "2003-02-21T09:08:04Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![upuaut](https://avatars.discourse-cdn.com/v4/letter/u/9fc348/32.png) [@upuaut](https://forum.kirupa.com/u/upuaut)\
**Post date:** [February 21, 2003, 9:08am UTC](https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040/1 "2003-02-21T09:08:04Z")

</div>

Lost and I are looking for php script which will look into a file folder, returning the number of pictures in that file folder, their names, and their dimensions. If anyone could help us out with developing these functions we would greatly appreciate it. (plus you’re name will be in the code where ever we use it, adding the the prestige.😛 )

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 21, 2003, 9:39am UTC](https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040/2 "2003-02-21T09:39:19Z")

</div>

I have this so far…

```php
<?php
$dir = opendir("images");
while (false != ($file = readdir($dir))) {
   if ($file == "." || $file == "..") continue;
   echo ("$file<BR>");
   }
?>

```

And that works all well and good, but how do I get the image dimensions as well? I tried, but it kept telling me there was an error with it, but I looked it up and I was using it right! I was wondering if I had to CHMOD the files, if so… one server I am on won’t let me do it, while the other server is being PHP retarded 😱 so I hope not.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 21, 2003, 10:21am UTC](https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040/3 "2003-02-21T10:21:57Z")

</div>

When I get home I’ll attempt the get image size method on my server, with Chmod checked. I’ll let you know if I have any luck.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 21, 2003, 6:24pm UTC](https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040/4 "2003-02-21T18:24:07Z")

</div>

Thanks david.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 21, 2003, 7:00pm UTC](https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040/5 "2003-02-21T19:00:50Z")

</div>

Howdy…

Some code snippet from my old file that goes with the file dimension…

```auto
$destinationFile = "./" . $theImageNum . ".jpg";
$picsize = getimagesize("$destinationFile");
$source_x = $picsize[0];
$source_y = $picsize[1];
echo($source_x . " : " . $source_y);

```

I’m not sure if it is viable though since PHP needs to open up the graphic file to get the dimension information… Maybe there is better way to do it???

Good luck… :cowboy:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 21, 2003, 7:03pm UTC](https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040/6 "2003-02-21T19:03:31Z")

</div>

Something like:

```php
<?php
$dir = opendir(".");
while($file = readdir($dir)){
if($file=="." or $file=="..") continue;
$dotposition = strrpos($file, ".");
$filename = substr($file, 0, $dotposition);
$extension = substr($file, 1 + $dotposition);
if($extension == "jpg" || $extension == "gif"){
$size = getImageSize($file);
echo "$filename.$extension height = $size[1] width = $size[0] <BR>";
}
}
?>

```

[edit] didn’t see CyanBlue’s post 🙂 [/edit]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 21, 2003, 7:09pm UTC](https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040/7 "2003-02-21T19:09:04Z")

</div>

Just 3 minutes early… Being lazy sometimes does trick… I was too lazy to sum up the total and yet, you did all the job, h88… :A+:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 21, 2003, 7:17pm UTC](https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040/8 "2003-02-21T19:17:33Z")

</div>

WOW!! Thanks guys!!

You know whats funny… what I was doing last night DID work… but it turns out your have to have the php file in the same directory as the images, I had it in the parent directory. 'DOH!

I will work a bit more with this to try and get it to do what I want, but don’t be surprised if I come back here begging for mercy/help 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 21, 2003, 8:02pm UTC](https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040/9 "2003-02-21T20:02:07Z")

</div>

That’s why I’ve been telling you that you need to get some sleep… :bad:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 21, 2003, 8:02pm UTC](https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040/10 "2003-02-21T20:02:54Z")

</div>

Well it was only 4:39am :sigh:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 21, 2003, 8:13pm UTC](https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040/11 "2003-02-21T20:13:02Z")

</div>

Well… That sounds about right… Never go to bed before the sun rises, eh??? =)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 21, 2003, 8:13pm UTC](https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040/12 "2003-02-21T20:13:49Z")

</div>

Us vampires do that :goatee:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 21, 2003, 10:30pm UTC](https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040/13 "2003-02-21T22:30:37Z")

</div>

Yes, we do that… I’m glad that it’s raining now… No sun up there… :evil:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 21, 2003, 10:54pm UTC](https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040/14 "2003-02-21T22:54:28Z")

</div>

MMMWWWWWAAAAHAHAHAHA

I wish it was thundering too… I like thunder :sleep:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 22, 2003, 12:29am UTC](https://forum.kirupa.com/t/looking-for-php-code-to-read-information-from-a-file-folder/14040/15 "2003-02-22T00:29:29Z")

</div>

sweet work guys.
