Jump to content

Help with accessing filesystem in a hosting server


georaldc

Recommended Posts

Ok, I'm pretty new to using PHP and I was wondering if someone could help me here. I've been trying to create a simple gallery and used PHP to access the folders and images and display them on my html page. I do this by creating gallery folders and naming them Gallery 1, Gallery 2 etc, and having the images inside them named 1.jpg, 2.jpg and so on. I grab them by counting the number of folders and files and using this counter as a basis for grabbing the directories names and images.

 

Now I got this to work just fine on my comp when testing it, but once I tried uploading the images and php files to a hosting server, I couldn't count the number of folders/images anymore. The code I used was just some snippet I saw in another forum:

 

$directory = "gallery/";
$handler = opendir($directory);
$totalFiles = 0;
while ($file = readdir($handler)) {
   if ($file != '.' && $file != '..') {
      $totalFiles++;
   }
}

 

$totalFiles doesn't return the number of gallery folder I have anymore once I test it after uploading it to a host

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.