XA-9 Posted December 13, 2010 Share Posted December 13, 2010 Hi everyone! I'm on a mission to make a simple (I hope :/ ) script that takes some files from a folder and sends them off to a snippet of javascript. I have a folder creatively named 'files' that is full of Google Earth .kml files. I want to get some PHP code to grab those files, and pass them to the javascript that handles the Google Earth plugin, which looks like this: var link = ge.createLink(''); var href = '<?php echo($testvar); ?>' link.setHref(href); var networkLink = ge.createNetworkLink(''); networkLink.set(link, true, true); The php in there is me testing out php-to-javascript variables, which seems to be working fine for a single file. My plan for the code was to: 1) Detect all the files in the folder 2) Make the paths for each file into string variables 4) Loop the above javascript once for each file The end result would be the kml files, which are all building models, populating the earth. The files in the folder will be added and removed all the time, so It has to check it every time. Unfortunately this had to be my first experience with php and so this is as far as I got: foreach(glob("files/"."*.kml") as $file){ echo $file." - "; } So, it lists out the files in the directory with a ' - ' between each one, but from there I've been lost for days Does anyone have some pointers on what to do with this? Thanks, Love ya! Quote Link to comment https://forums.phpfreaks.com/topic/221492-gathering-files-defacing-the-earth-with-them/ Share on other sites More sharing options...
Adam Posted December 13, 2010 Share Posted December 13, 2010 How do you link the JS and PHP; via an AJAX call or the result simply echoed straight into the JavaScript? Quote Link to comment https://forums.phpfreaks.com/topic/221492-gathering-files-defacing-the-earth-with-them/#findComment-1146581 Share on other sites More sharing options...
XA-9 Posted December 13, 2010 Author Share Posted December 13, 2010 at the moment I just echo it var href = '<?php echo($testvar); ?>' but that was really just for proof of being able to do it Quote Link to comment https://forums.phpfreaks.com/topic/221492-gathering-files-defacing-the-earth-with-them/#findComment-1146594 Share on other sites More sharing options...
Adam Posted December 13, 2010 Share Posted December 13, 2010 How do you 'loop the JavaScript' then? Quote Link to comment https://forums.phpfreaks.com/topic/221492-gathering-files-defacing-the-earth-with-them/#findComment-1146622 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.