I'm trying to read a directory with php's scandir on Google App Engine. The files within the folder 'img' are definitely reachable, but I am trying to get a list of all files in the folder. What's wrong?
All files are apparently uploaded correctly, so app.yaml should be fine. Is it a PHP error or a GAE restriction?
This is my main php-script, run when accessing my site's /:
<?php
$dir = 'img';
if (is_dir($dir)) {
//this code is never reached:
echo "directory exists :-)";
$filenames = scandir($dir, 0);
print_r($filesnames);
} else {
echo "No such directory";
}
// this works:
echo "<div>
<img src=\"/img/example.png\">
</div>";
// this works:
$files1 = scandir(getcwd());
print_r($files1);
?>
opendir($dir) doesnt help either.
Here's my app.yaml:
application: mypage
version: 1
runtime: php55
api_version: 1
handlers:
# image files
- url: /img/(.*\.(bmp|gif|ico|jpeg|jpg|png))
static_files: img/\1
upload: img/(.*\.(bmp|gif|ico|jpeg|jpg|png))
- url: /.*
script: helloworld.php
# this is probably redundant:
- url: /img
static_dir: img
EDIT: Adding this line to the image files section (not necessarily the img folder) solved the problem: application_readable: true