opendir
operates on directories on a filesystem, not HTTP URIs.
While some HTTP URIs return directory listings (the one you are using doesn’t, it is a 404 error), those listings as HTML documents generated by the webserver and are not actual directories.
So please change value of $directory
variable.
For Example:
Current value in $directory = "http:/localhost/WP/wp-content";
Need to be correct like : $directory ='<wwwroot>/WP/wp-content';
NOTE: [opendir()][1]
is used to open a local directory and since PHP 5.0.0 on an ftp directory.