PandaPHP Posted June 22, 2010 Share Posted June 22, 2010 I have 30,000 files to upload onto my webspace but there is a file limit of 1000 per directory so I must use several directories. $dir = "/home/freefla/public_html/"; $folderid = 1; $filecount = count(glob($dir . $folderid . "/.swf")) ; Firstly whats wrong with my code above as it always returns 0 or 1 files regardless? Secondly how do I put this into a for loop to automatically increase the folder ID when the previous folder is full (for 5 files for testing purposes). I have tried to do this myself but failed Link to comment https://forums.phpfreaks.com/topic/205503-file-counter/ Share on other sites More sharing options...
PandaPHP Posted June 22, 2010 Author Share Posted June 22, 2010 I have the file counter working but I am having a rough time trying to figure out how to loop it. Any ideas? Link to comment https://forums.phpfreaks.com/topic/205503-file-counter/#findComment-1075381 Share on other sites More sharing options...
PandaPHP Posted June 22, 2010 Author Share Posted June 22, 2010 Deleted Link to comment https://forums.phpfreaks.com/topic/205503-file-counter/#findComment-1075387 Share on other sites More sharing options...
PandaPHP Posted June 22, 2010 Author Share Posted June 22, 2010 <?php $dir = "/home/freefla/public_html/domains/free-arcade-games.org.uk/wp-content/games/"; $fid = 1; do { if (file_exists($dir . $fid)){ $counter = count(glob($dir . $fid . "/*.*")); echo "folder " . $fid . " has " . $counter . " files <br />"; if ($counter >= 6) { $fid++; } } else { echo "folder " . $fid . " does not exist <br />"; echo "creating folder " . $fid . "<br />"; mkdir($dir . $fid, 0755); } } while ($counter >= 6); ?> Fixed, how does this look? Link to comment https://forums.phpfreaks.com/topic/205503-file-counter/#findComment-1075391 Share on other sites More sharing options...
Ruzzas Posted June 22, 2010 Share Posted June 22, 2010 <?php if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "$file\n"; } } closedir($handle); } ?> Link to comment https://forums.phpfreaks.com/topic/205503-file-counter/#findComment-1075409 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.