Myshka
asked on
Why PHP Script for read directory content no update directory changes at second execution
I have php script for read a directory of image files, at first time, get the content right but at the second and another times result of php script is the same to de first read.
The content of directory is change for another php script. When I try to read de new content, result is the same every time run the php script.
Please, any idea for a solution?
Thank in advance
The content of directory is change for another php script. When I try to read de new content, result is the same every time run the php script.
Please, any idea for a solution?
Thank in advance
<?php
header( "cache-control: private" );
header( "pragma: no-cache" );
header("Content-Type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>"."\n";
$directory = "../".$_GET['directory'];
echo "<gallery>"."\n";
ExportDirectoryXML($directory);
echo "</gallery>";
function ExportDirectoryXML($base)
{
if ($dir = @opendir($base))
{
while ($file = readdir($dir))
{
if ($file{0} != ".")
{
if (is_dir($base . "/" . $file))
{
}
else
{
$ext = @substr($file, (@strrpos($file, ".") ? @strrpos($file, ".") : @strlen($file)), @strlen($file));
$fname = basename($file,$ext);
$imgsrc= $base . "/" . $file;
$imgsrc= substr($imgsrc, 3);
echo "<image>"."\n";
echo "<label>".$file."</label>"."\n";
echo "<path>".$imgsrc."</path>"."\n";
echo "</image>"."\n";
}
}
} //end while
closedir($dir);
} // end if
} //end function
?>
What version of PHP?
The script you've got doesn't change anything, just reports back the files found.
What changes are made to the files?
What changes are made to the files?
ASKER
This is the case:
1. I use above script for read directory content of images files. For example, result are 10 image files content.
2. I use another script for add new image files to the same directory read from 1. For example, add 20 new image files to directory.
3. I execute again de first script for reread directory content, but result only show first 10 image files hoe directory content, not 30 image files how there are.
Php version is 5.x
1. I use above script for read directory content of images files. For example, result are 10 image files content.
2. I use another script for add new image files to the same directory read from 1. For example, add 20 new image files to directory.
3. I execute again de first script for reread directory content, but result only show first 10 image files hoe directory content, not 30 image files how there are.
Php version is 5.x
Are you sure the second script is writing to the correct folder?
ASKER
Yes, I see directory content from another program and directly.
First, I see all is correct before request a solution!
I think in cache problem or php refreshing content.
First, I see all is correct before request a solution!
I think in cache problem or php refreshing content.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You are fantastic, all is ok now.
Very tanks.
Very tanks.
ASKER
Thank, you are my good
Glad to have helped.