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
Asked
Active
Viewed 339 times
-2
-
This will help: http://php.net/manual/en/function.getcwd.php – ScottMcGready Nov 25 '15 at 01:11
-
3Possible duplicate of [PHP list of specific files in a directory](http://stackoverflow.com/questions/3062154/php-list-of-specific-files-in-a-directory) – Machavity Nov 25 '15 at 01:12
-
@Dagon 1= ? instead of =? – Hurricane Development Nov 25 '15 at 01:18
2 Answers
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

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