-2

There is a way in PHP for run a script that retrieve the full URL of every files within the folder where the scipt is executed? Thank you

Gixone
  • 27
  • 6

2 Answers2

1

Getting the URL is not so easy. PHP does not always work in a manner of path relating to URL. Your environment might be setup so the path=URL, or it might be setup so that all requests are sent to one PHP controller that then computes the result.

To find the paths however is quite straight forward.

$directory = __DIR__; //Gets the current directory path
$contents = scandir($directory); //Get all files and folders from the $directory
$contents = array_diff($contents, array('..', '.')); //If a linux environment, this removes the ".." and "." occurences

Scandir documentation.

Hurricane Development
  • 2,449
  • 1
  • 19
  • 40
0

You can use iterator to go over the directory. Then use pathinfo() to get the complete path of the file.

user3307291
  • 708
  • 1
  • 8
  • 11