dmcdivitt Posted December 10, 2008 Share Posted December 10, 2008 I'm just getting started with PHP. Done many other languages. I need to scan the directory on the server the script resides in for all .CSV type files, then produce a page with a link to each file for download. Is there a way to discover the location of the excuting script without having to hard code? Thanks Link to comment https://forums.phpfreaks.com/topic/136401-solved-newbie-list-of-files-at-real-path/ Share on other sites More sharing options...
Mchl Posted December 10, 2008 Share Posted December 10, 2008 Use $_SERVER['PHP_SELF'] Read more Link to comment https://forums.phpfreaks.com/topic/136401-solved-newbie-list-of-files-at-real-path/#findComment-711709 Share on other sites More sharing options...
trq Posted December 10, 2008 Share Posted December 10, 2008 You won't even need that. <?php foreach (glob('*.CSV') as $file) { echo "<a href='$file'>$file</a><br />"; } ?> Link to comment https://forums.phpfreaks.com/topic/136401-solved-newbie-list-of-files-at-real-path/#findComment-711839 Share on other sites More sharing options...
dmcdivitt Posted December 11, 2008 Author Share Posted December 11, 2008 I see PHP resolves the virtual or hosted path to the real path on the hardware, which is neat. Java and other languages don't do that. Link to comment https://forums.phpfreaks.com/topic/136401-solved-newbie-list-of-files-at-real-path/#findComment-712487 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.