I am trying to call a random .php file from a specific folder in my directory.
If I place the files in the main folder (root directory), it works fine however, My webpage will have to go deeper at some point so if I am unable to call files from any point in the directory, this could get quite messy.
So this works perfectly for me by having the files in the same folder
<div class="col-sm-3">
<?php readfile(rand(1,99).".php");?>
</div>
However, when I try to place the random files into a specific folder (in the root directory), It does not return the .php file. I have tried the following
1. <?php readfile("/Myfolder/".rand(1,99).".php");?>
2. <?php readfile("Myfolder".rand(1,99).".php");?>
3. <?php include("/Myfolder/.rand(1,99).".php");?>
And all sorts of other combinations of ../ , "/ , ../../ etc
I also need to be able to call files from any point in the directory ie "../../"
I am new to php and this at the moment is really stopping me from progressing so any help in is very much appreciated.
Cheers
Aucun commentaire:
Enregistrer un commentaire