<?php // header("Content-Type: text/plain"); $boundary = 'ThisRandomString'; header("Content-type: multipart/x-mixed-replace;boundary={$boundary}"); header("Pragma:no-cache"); set_time_limit(0); // ob_implicit_flush(); print "--$boundary "; for( $i = 0; $i < 10; $i++ ) { // echo str_repeat( ' ', 1024 ); print "Content-Type: image/jpeg "; // echo file_get_contents( $i % 2 . '.jpg' ); readfile( $i % 2 . '.jpg' ); print " --$boundary "; ob_flush(); flush(); clearstatcache(); usleep( 500000 ); } /* set_time_limit(0); $file = "1.jpg"; $sep = "gIrLsKiCkAsSiTsAySsOoNaTsHiRt"; header("Content-Type: multipart/x-mixed-replace; boundary=$sep"); //这里是关键哦,看看MIME类型说明 //你会明白 print "--$sep "; print "Content-Type: image/jpeg "; readfile($file); print " --$sep "; */
转载于:https://my.oschina.net/waterPlants/blog/1512283