<?php $directory = "./images/featured/"; $images = glob($directory . "*.*"); ?>JS:
var imgArr = <?= json_encode($images) ?>;then I put it in a theme on wordpress on my website, and it still worked.
The php and JS was in themes/tiu/inc/ and images in themes/tiu/images/featured/, for some reason ../ was referring to the root directory instead of up one directory so the directory variable looked like this:
$directory = "../tiu/wp-content/themes/tiu/images/featured/";And this all worked.
This is where it stops working.
Then I went to put it on the site I've been making it for, which used a different web host.
Now it doesn't work but nothing's changed other than the web host.
I am using this to test:
var dir = "<?php echo $images?>"; alert(dir);and that returned an empty string (which it shouldn't, it should return the url for the first image in the folder).
I have noticed though, even though the folders have read permissions, they are forbidden access.
I put Options +Indexes in a .htaccess file in the images folder which made images and featured browsable but did not fix my problem.
I have tried:
- using an absolute path
- changing ../tiu/wp-content/themes/tiu/images/featured/ to ../images/featured/ which is how I thought it should originally be (up on directory, into images, into featured).
- using $_SERVER('DOCUMENT_ROOT') - this filled up the array pointing to my images 'ex01.jpg' etc... but the path to it was invalid
- using "http://www.".$_SERVER('SERVER_NAME') - this was essentially the same as using an absolute path and did not work
Anyone know what the heck is going on?
This post has been edited by JD.CoolPenguin: 30 January 2013 - 10:54 AM