Jump to content

file extension and trigger


nisroc

Recommended Posts

What i am trying to do is create a gallery by using the paths to a folder as links, example is <a href="../gallery/scenes"> ... and ../gallery/cities.... I have a sidebar menu populated like this and works fast so i wish to keep it.  Now in my main content area i have a php script that will read the directory contents and display the images in the folder into a div.

 

I have two questions;


<?php

$path = "gallery/scenes";
$dh = opendir($path);
while (false !== ($file = readdir($dh))) {
	if ($file != "." && $file != "..") {
	echo "<img src=\"$path/$file\" height=\"100\" width=\"100\" />";
	}
}

closedir ($dh);
?>

 

 

First is, folders are generating thumbs.db file when the images are called to the page. it has not affected me that i can see but i would like to cancel it out from the script anyway. To do so i wish to filter the db extension, but i do not know how, A little shove/push in right direction should help me here.

 

Second Like i said in fist paragraph, i want to have a links that that point to a directory and that when clicked will trigger the script above. My problem is how would i trigger this script from a link? I really do not wish to create whole new page for each gallery.

 

Thanks in advance for any help on these problems

Link to comment
Share on other sites

for 'first'

 

change

      if ($file != "." && $file != "..") {

      echo "<img src=\"$path/$file\" height=\"100\" width=\"100\" />";

      }

 

 

to

 

      if (($file != ".") && ($file != "..") && (substr($file,strlen($file) - 3) != '.db')) {

      echo "<img src=\"$path/$file\" height=\"100\" width=\"100\" />";

      }

 

for 'second'

you'd want htaccess :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.