Jump to content

wlile loop


redarrow

Recommended Posts

wont work why dont no!

 

<?php

ob_start();

$images=opendir("upload_new/test/");

while(readdir($images)== TRUE) {

echo "Filename: $file\n";
   
$filename = "upload_new/test/$file";
header('Content-type: image/png');
header('Content-length: '.filesize($filename));
readfile($filename);
} 
ob_end_flush();

?>

Link to comment
https://forums.phpfreaks.com/topic/39465-wlile-loop/#findComment-190411
Share on other sites

Maybe you should try something like this:

<?php
// Note that !== did not exist until 4.0.0-RC2

if ($handle = opendir('/path/to/files')) {
   echo "Directory handle: $handle\n";
   echo "Files:\n";

   /* This is the correct way to loop over the directory. */
   while (false !== ($file = readdir($handle))) {
       echo "$file\n";
   }

   /* This is the WRONG way to loop over the directory. */
   while ($file = readdir($handle)) {
       echo "$file\n";
   }

   closedir($handle);
}
?> 

I got this straight off the manual, try to see if the readdir part works fine, because I dont see any problems in your code...

Ted

Link to comment
https://forums.phpfreaks.com/topic/39465-wlile-loop/#findComment-190421
Share on other sites

the idear is to loop  throw the directory and show all throw the while loop.

 

does not work.

 

<?php

header("Content-type: image/png");

$images=opendir("upload_new/test/");

while(FALSE!==($file = readdir($images))){

$im    = imagecreatefrompng($images.$file);

$orange = imagecolorallocate($im, 220, 210, 60);

$px    = (imagesx($im) - 7.5 * strlen($string)) / 2;

imagestring($im, 3, $px, 9, $string, $orange);

imagepng($im);

imagedestroy($im);

closedir($images);
}
?>

Link to comment
https://forums.phpfreaks.com/topic/39465-wlile-loop/#findComment-190423
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.