![]() |
Random File Generator
Yeah hey guys I am new here and fairly new to php. I was wondering if someone could give me a hand to write a code. Basically what I want to be able to do is when the website user clicks on a link, it generates a random image on a separate page. This random image would just be pulled from a folder with a bunch of images. Any help would be great.
Thanks! Austin |
you can get an array of all the images in that folder by calling the function scandir and then count the number of arrays in it and call rand function to make it randomly pick...
PHP Code:
|
thanks a lot. I just have one problem.
When I click the link to generate the random image, it works but it shows the image as "broken" everytime. When i copy paste the image url into a new tab, the url shows it pulling from the main directory instead of the folder where I generated it from. Any ideas? |
OH and I know it has something to do with the
<img src={$images[$rand]}> part. I just don't know what to change it to. |
| All times are GMT +1. The time now is 04:22 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.