Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // before you just copy and paste this logic please understand that there has already been a connection to said server
- // we are basically trying to find a specific file, in this case an svg image, by scanning the directory and looping
- // through until we find said file. Then we render that which will provide the actual path. This isn't meant as
- // a permanent fix for rendering files, this case images, but to check as thoroughly as possible if that actual
- // file exists. Change the resources_path_name to the specific path you would like to target.
- // we pass a $path object through the function that we later call by doing listIt('path_name');
- function listIt($path) {
- $items = $path;
- foreach($items as $item){
- if($item != "." AND $item != "..") {
- if (is_file($path . $item)) {
- // this is the file code for selected file
- } else {
- // this is the directory path
- listIt($path . $item . "/");
- }
- }
- }
- // this is a variable to access the 6th object in an array of objects, if you know which object you are trying to find
- // then just change this to that file placement
- // $resources = scandir($resources_directory[6]);
- $startfolder=scandir($_SERVER['DOCUMENT_ROOT']);
- $startfolder=$_SERVER['DOCUMENT_ROOT'].'/resources_path_name';
- $files=array();
- foreach( new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $startfolder, RecursiveDirectoryIterator::KEY_AS_PATHNAME ), RecursiveIteratorIterator::CHILD_FIRST ) as $file => $info ) {
- if( $info->isFile() && $info->isReadable() ){
- $files[]=array('filename'=>$info->getFilename(),'path'=>realpath( $info->getPathname() ) );
- }
- }
- $svgimage = print_r($files[57]["path"],true);
- //this is for visually checking the path
- //echo '<pre>',$svgimage,'</pre>';
- //die();
- //calling the function, as stated before, and passing a path from the variable of $startfolder
- //var_dump(listIt($startfolder));
- //die();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement