lopes_andre Posted December 20, 2010 Share Posted December 20, 2010 Hi, I need to read files from a web directory. I have tested the "opendir" function but it doesn't work. <?php if ($handle = opendir('http://geolite.maxmind.com/download/geoip/database/GeoLiteCity_CSV')) { echo "Directory handle: $handle\n"; echo "Files:\n"; /* This is the correct way to loop over the directory. */ while (false !== ($file = readdir($handle))) { echo "$file\n"; } /* This is the WRONG way to loop over the directory. */ while ($file = readdir($handle)) { echo "$file\n"; } closedir($handle); } ?> How can I read files from a directory like this? Best Regards, Link to comment https://forums.phpfreaks.com/topic/222199-opendir-do-read-a-web-directory-possible/ Share on other sites More sharing options...
johnny86 Posted December 20, 2010 Share Posted December 20, 2010 echo file_get_contents("http://geolite.maxmind.com/download/geoip/database/GeoLiteCity_CSV"); Link to comment https://forums.phpfreaks.com/topic/222199-opendir-do-read-a-web-directory-possible/#findComment-1149477 Share on other sites More sharing options...
menator Posted December 20, 2010 Share Posted December 20, 2010 You might want to have a look at scandir Link to comment https://forums.phpfreaks.com/topic/222199-opendir-do-read-a-web-directory-possible/#findComment-1149507 Share on other sites More sharing options...
lopes_andre Posted December 20, 2010 Author Share Posted December 20, 2010 Hi, "file_get_contents" has done the job. Thanks. Link to comment https://forums.phpfreaks.com/topic/222199-opendir-do-read-a-web-directory-possible/#findComment-1149593 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.