Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling a PHP script to get image urls
    primarykey
    data
    text
    <p>My path is like this</p> <p>/website/php<br> /website/javascript<br> /website/photographer/index.html<br> /website/photographer/photos </p> <p>I have a javascript which displays a photo gallery for the photos in the folder. Using ajax with jquery, it calls a PHP file that returns the image urls in "photos" so that the javascript can then set up the gallery, etc.</p> <p>The problem is that I can't seem to get PHP to access the "photos" folder. See, I have a bunch of different photographer pages which do the same thing, so I'm trying to have one PHP file and one javascript file, but different directories.</p> <p>The method I devised was to send "window.location.pathname" in the ajax get call so that php can get the directory the current page is in, and then simply search the "photos" folder in that directory.</p> <pre><code>chdir($_GET["currentPath"] . "photos"); //change the directory so we just get the file names echo json_encode(glob("*.jpg")); </code></pre> <p>I get this error: Warning: chdir() [function.chdir]: No such file or directory (errno 2) in /hermes/bosweb/web054/b541/ipg.danielechevarriacom/testing/oneonethousand_test/php/images.php on line 4 []</p> <p>And when I</p> <pre><code>echo $_GET["currentPath"] . "photos"; </code></pre> <p>It prints: "/testing/oneonethousand_test/steele/photos"</p> <p>That is the correct directory where the photos are, so I don't know why this isn't working. I am assuming this has to do with how chdir works.</p> <p>I don't want to do chdir("../steele/photos") because I will have many directories and I want to have the PHP file stay general. I just want to be able for javascript to tell php where the current directory is and then PHP switches to that directory. Why doesn't this work?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload