cgm225 Posted July 7, 2007 Share Posted July 7, 2007 The following FOR loop does not echo anything until it is complete. Is there a way to make it echo while it is executing, i.e. each time it passes through, echo the "thumbnail generated" statements? if ($action == "generate_all") { $image = 0; for($i = 1; $i >= 0; $i++) { buffer($image); if (file_exists("$photos_server_path/photos/$album/$buffer$image.jpg")) { echo "$buffer$image: "; if (file_exists("$photos_server_path/photos/$album/thumbnails/large_thumbnail-$image.jpg")) {} else { system("convert $photos_server_path/photos/$album/$buffer$image.jpg -resize 500x -quality 100 $photos_server_path/photos/$album/thumbnails/large_thumbnail-$image.jpg"); echo "Large thumbnail generated! | "; } if (file_exists("$photos_server_path/photos/$album/thumbnails/small_thumbnail-$image.jpg")) {} else { list($image_width, $image_height) = getimagesize("$photos_server_path/photos/$album/$buffer$image.jpg"); if ($image_height > $image_width) { $small_thumbnail_height = ceil(250 * ($image_width/$image_height)); } else { $small_thumbnail_height = ceil(250 * ($image_height/$image_width));} system("convert $photos_server_path/photos/$album/$buffer$image.jpg -resize 250x -gravity center -quality 100 -crop 250x$small_thumbnail_height+0+0 $photos_server_path/photos/$album/thumbnails/small_thumbnail-$image.jpg"); echo "Small thumbnail generated!<br>"; } $next_image_addage = $image; $image = $next_image_addage + 1; } else { $i = -5; } } } Link to comment https://forums.phpfreaks.com/topic/58789-solved-why-doesnt-script-echo-thumbnail-generated-while-running-through-for-loop/ Share on other sites More sharing options...
Psycho Posted July 7, 2007 Share Posted July 7, 2007 No. A php created page is not delivered to the browser until the script completes. You would have to involve some sort of AJAX solution to do what you propose. Link to comment https://forums.phpfreaks.com/topic/58789-solved-why-doesnt-script-echo-thumbnail-generated-while-running-through-for-loop/#findComment-291707 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.