Dynamically Rename Images
| From: | Andrew Hucks | Date: | Sun, 03 May 2009 02:19:30 +0000 |
| Subject: | Dynamically Rename Images | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-292228@lists.php.net to get a copy of this message | ||
Is it possible to rename images dynamically?
Say that I had something like image1.png, and I don't want to rename
it on the server. I'm working on an image rotater for a forum that
doesn't allow anything but image files as signatures.
Here's my code so far:
<?php
//LolRotator
//add images. not too hard.
$images = array("image1.png", "image2.png", "image3.png");
//which one do we gets?
$show = rand(0, (count($images)-1));
//i r got u picture.
echo '<img src="'.$images[$show].'"/>';
?>
I used mod_rewrite, which makes it from image.php to image.png. But,
because the files aren't named image.png, it doesn't work. I need to
figure out somethign between lines 8 and 10 to change the file name to
image.png.
Is there a way to do this?