I have spent many hours trying to figure this out, though it seems it should be quite straightforward. I'm working on a website with a javascript file that generates html code given the pathname of a folder. Currently I am able to pull images from those folders no problem, but am trying to figure out .txt files...
document.write('<img src="folder/' + info[i] + '/picture.png">');
info[i] is an array storing the name of each folder I want to grab files from...
So in every folder there is an image called picture.png, there is also a text file called details.txt
Is it possible to have something like...
var details;
details = readFile('"folder/' + info[i] + '/details.txt"');
document.write(details);
I have also tried the following code, I simply can't get the .txt contents to showup in the browser. The .txt file has words in it, and is in the same folder as the html file... If I can get the code below to work and display the file on the webpage, then I'll be able to answer the rest of my question.
<html>
<body>
Contents:
<?php $file_content = file_get_contents('details.txt'); ?>
<script type="text/javascript">
var details = '<?php echo $file_content ; ?>';
document.write(details);
</script>
</body>
</html>
Thank you for your time, any help is greatly appreciated.