pixelvoodoo22
03-07-2010, 09:27 AM
Hi,
A real simple one for anyone who understands php I should imagine.
This script I found works perfectly. I make a call to the php, and it returns some xml to tell me all files within the folder it lives in.
What I'm trying to do is have this script in a different folder to my images. So I'm changing the opendir bit to "images" or "/images" or "../images" or "images/" and nothing works at all! is there something I'm missing? A special way to write the path out of where the php is sitting, or another line I need to change in the php?
It's driving me mad, any help appreciated!
Thanks
<?php
$xml = '<?xml version="1.0"?'.'><images>';
$dir = opendir(".");
while ( ($file=readdir($dir)) !== false ) {
if ( !is_dir($file) ){
$pic = @getimagesize($file);
if($pic != false && $pic[2] == 2){
$xml .= '<img src="'.$file.'" width="'.$pic[0].'" height="'.$pic[1].'" />';
}
}
}
$xml .= '</images>';
echo $xml;
?>
A real simple one for anyone who understands php I should imagine.
This script I found works perfectly. I make a call to the php, and it returns some xml to tell me all files within the folder it lives in.
What I'm trying to do is have this script in a different folder to my images. So I'm changing the opendir bit to "images" or "/images" or "../images" or "images/" and nothing works at all! is there something I'm missing? A special way to write the path out of where the php is sitting, or another line I need to change in the php?
It's driving me mad, any help appreciated!
Thanks
<?php
$xml = '<?xml version="1.0"?'.'><images>';
$dir = opendir(".");
while ( ($file=readdir($dir)) !== false ) {
if ( !is_dir($file) ){
$pic = @getimagesize($file);
if($pic != false && $pic[2] == 2){
$xml .= '<img src="'.$file.'" width="'.$pic[0].'" height="'.$pic[1].'" />';
}
}
}
$xml .= '</images>';
echo $xml;
?>