I am trying to list files in a directory I names jss by putting an index.php script in the same folder.
Unfortunately, I have not been able to succeed in doing this but got the error messages shared below after the main script used.
Any help will be appreciated.
Here is the script I used:
?>
<?php function file_get_contents_curl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $data = curl_exec($ch); curl_close($ch); return $data; } foreach ($files as $file){ $html = file_get_contents_curl("digitallib/classnotes/jss/$file"); //parsing begins here: $doc = new DOMDocument(); @$doc->loadHTML($html); $nodes = $doc->getElementsByTagName('jss'); //get and display what you need: $title = $nodes->item(0)->nodeValue; $metas = $doc->getElementsByTagName('meta'); if ($title !="403 Forbidden"){ echo "$title". '';} } ?>
Here is the error I got:
Warning : Undefined array key “submit digitallib/classnotes/jss/” in C:\xampp\htdocs\digitallib\classnotes\jss\index.php on line 2
Warning : opendir(digitallib/classnotes/jss/): The system cannot find the path specifi (code: 3) in C:\xampp\htdocs\digitallib\classnotes\jss\index.php on line 13
Warning : opendir(digitallib/classnotes/jss/): Failed to open directory: No such file or directory in C:\xampp\htdocs\digitallib\classnotes\jss\index.php on line 13
Fatal error : Uncaught TypeError: readdir(): Argument #1 ($dir_handle) must be of type resource or null, bool given in C:\xampp\htdocs\digitallib\classnotes\jss\index.php:15 Stack trace: #0 C:\xampp\htdocs\digitallib\classnotes\jss\index.php(15): readdir(false) #1 {main} thrown in C:\xampp\htdocs\digitallib\classnotes\jss\index.php on line 15