0

Access random file from my server

For example, I want to access a random image from /ex/images. I habe 3 files in this folder: bathroom.png sleep.png grass.png Is there a way to access one of these files randomly?

27th Mar 2018, 7:32 AM
Manuel 48
Manuel 48 - avatar
3 Answers
+ 3
1) collect n images name in a array b 2) generate a random number r which value is from 0 to n-1 3) b[r] is your random image name
27th Mar 2018, 8:15 AM
KrOW
KrOW - avatar
0
@KrOW Is 1 possible with js or Jquery?
27th Mar 2018, 8:40 AM
Manuel 48
Manuel 48 - avatar
0
Sure, but like all client-side code, you will expose some data and i dont know if it allowed in your context... But, like sql_assassin ask you, what is your purpose?
27th Mar 2018, 10:23 AM
KrOW
KrOW - avatar