Jump to content


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


Quick help with a random image script

Recommended Posts


$path = '.';

  if ($handle=opendir("$path")) {
      while(false !== ($file = readdir($handle))) { 
                if ($file != "." && $file != "..") {
$files[count($files)] = $file;

  if(substr($files[$random],-3)=='gif') header("Content-type: image/gif");
  elseif(substr($files[$random],-3)=='jpg') header("Content-type: image/jpeg");
  elseif(substr($files[$random],-3)=='jpeg') header("Content-type: image/jpeg");
  elseif(substr($files[$random],-3)=='png') header("Content-type: image/png");

The above is a random image script, it is used to put a random picture on the front page of my website. The URL to this website is www.nowthatshumor.com if you need an example of what I'm asking.  I'm not that good at PHP but I'm sure this is quick simple.

I'm looking how to edit the above so it displays a text link saying 'Add to Myspace' and will open a new window with the HTML code i wish to display. I'd greatly apperciate this very much. The html code can be displaced as a static text or in a text box where it can be copied and pasted. I'd great appericate this.


Just have the text area box with the HTML code below it, basicly where it auto highlights it all. I'm sure you know that i mean. thank you

Share this post

Link to post
Share on other sites


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.