View Full Version : looking for php code to read information from a file folder
upuaut
February 21st, 2003, 04:08 AM
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.:P )
lostinbeta
February 21st, 2003, 04:39 AM
I have this so far...
<?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 :scream: so I hope not.
upuaut
February 21st, 2003, 05:21 AM
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.
lostinbeta
February 21st, 2003, 01:24 PM
Thanks david.
CyanBlue
February 21st, 2003, 02:00 PM
Howdy...
Some code snippet from my old file that goes with the file dimension...
$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:
h88
February 21st, 2003, 02:03 PM
Something like:
<?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>";
}
}
?>
didn't see CyanBlue's post :)
CyanBlue
February 21st, 2003, 02:09 PM
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+:
lostinbeta
February 21st, 2003, 02:17 PM
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 :)
CyanBlue
February 21st, 2003, 03:02 PM
That's why I've been telling you that you need to get some sleep... :bad:
lostinbeta
February 21st, 2003, 03:02 PM
Well it was only 4:39am :sigh:
CyanBlue
February 21st, 2003, 03:13 PM
Well... That sounds about right... Never go to bed before the sun rises, eh??? =)
lostinbeta
February 21st, 2003, 03:13 PM
Us vampires do that :goatee:
CyanBlue
February 21st, 2003, 05:30 PM
Yes, we do that... I'm glad that it's raining now... No sun up there... :evil:
lostinbeta
February 21st, 2003, 05:54 PM
MMMWWWWWAAAAHAHAHAHA
I wish it was thundering too.... I like thunder :sleep:
upuaut
February 21st, 2003, 07:29 PM
sweet work guys.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.