Guest Posted March 7, 2008 Share Posted March 7, 2008 Im quite new to the php scene and am trying to develop my site using php.Got a few books and done a few tuts. But where i am stuck is, i need a script that can display on my site so say if a folder on my server has a file in it or not :S e.g if the folder has test.jpg in it the site will say folder full and if there is nothing in the folder to display folder empty. Hope ya's can help Many thanks Ma9ic. Link to comment https://forums.phpfreaks.com/topic/94861-first-timer-php-help/ Share on other sites More sharing options...
Rohan Shenoy Posted March 7, 2008 Share Posted March 7, 2008 Use file_exists() function Link to comment https://forums.phpfreaks.com/topic/94861-first-timer-php-help/#findComment-485910 Share on other sites More sharing options...
Guest Posted March 7, 2008 Share Posted March 7, 2008 Thank you for you help , im nearly there but how would i use this if i dont know what the name of the file in the folder will be? Hope ya can help so thats me solved Link to comment https://forums.phpfreaks.com/topic/94861-first-timer-php-help/#findComment-485934 Share on other sites More sharing options...
moon 111 Posted March 7, 2008 Share Posted March 7, 2008 You can use this: <?php $dir = 'directory'; echo (count(glob("$dir/*")) === 0) ? "$dir is empty" : "$dit is not empty"; ?> Hope it helps Link to comment https://forums.phpfreaks.com/topic/94861-first-timer-php-help/#findComment-485944 Share on other sites More sharing options...
Guest Posted March 7, 2008 Share Posted March 7, 2008 Thanks job done, many thanks for you help Link to comment https://forums.phpfreaks.com/topic/94861-first-timer-php-help/#findComment-486321 Share on other sites More sharing options...
conker87 Posted March 7, 2008 Share Posted March 7, 2008 Would a function like the following work too? Might use this if it does. <?php directoryExists($dir) { return (count(glob("$dir/*")) === 0) ? "$dir is empty" : "$dir is not empty" } ?> Link to comment https://forums.phpfreaks.com/topic/94861-first-timer-php-help/#findComment-486328 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.