note 38273 deleted from function.base64-encode by pollita

From: Date: Mon, 15 Dec 2003 02:34:28 +0000
Subject: note 38273 deleted from function.base64-encode by pollita
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-61963@lists.php.net to get a copy of this message
Note Submitter: King Killa ---- I wanted to make my php file act as an image in two ways. I wanted to be able to link to it as <img src=image.php> and I wanted to be able to go to just image.php and see it. Here is what I did(this displays a random image): <? header(" Content-Type: image/png"); header(" Content-Disposition: inline"); $file1 = "list.txt"; $juggalo = file($file1); srand((double)microtime()*1000000); $r = rand(0, sizeOf($juggalo)-1); $file = "$juggalo[$r].png"; $file = str_replace("\n", "", $file); $file = str_replace("\r", "", $file); $handle = fopen($file,'rb'); $file_content = fread($handle,filesize($file)); fclose($handle); if(isset($_SERVER[HTTP_REFERER])) { echo "$file_content"; } else { $encoded = chunk_split(base64_encode($file_content)); echo '<img src="data:image/png;base64,'.$encoded.' ">'; } ?>

« previous php.notes (#61963) next »