e-mail: Jim.Maxka@nau.edu
# Put the SERVER PATH to image directory.
# INCLUDE trailing slash
$dir = "/home/jmaxka/public_html/chm238/graphics/";
# Put the HTML PATH to image directory.
# DO NOT include trailing slash
$html_dir = "http://jan.ucc.nau.edu/~jmaxka/chm238/graphics";
$dir_handle = opendir($dir);
$image_array = array();
# This opens up the image directory, grabs all files with a ".jpg" extension
# and puts them into an array. You can set whatever extension you'd like here.
# Just switch out the .jpg for .gif, etc. If you have more than one extension,
# replace this line with something like this:
# if (($file !=".") && ($file !="..") && (substr($file, -4) == ".jpg") || (substr($file, -4) == ".gif"))) {
# This will pull up all .jpg OR .gifs. If you name all the images you want to pull
# a certain way (example, image-thumb.jpg or image.thumb.jpg) you can do this:
#if (($file !=".") && ($file !="..") && (substr($file, -10) == ".thumb.jpg")) {
# basically you want to put the extension in quotes and then count how many characters
# it is and place that after $file, -
while ($file = readdir($dir_handle)) {
if (($file !=".") && ($file !="..") && (substr($file, -4) == ".gif")) {
$file_name = "$html_dir/$file";
#echo "This is a file $file_name ";
$image_array[$file_name] = $file_name;
}
}
# sorts the array. For some reason this won't wor
# unless this is done. Can anyone tell me why?
sort($image_array);
$count = sizeof($image_array);
#echo "This is count = $count ";
# item in the array a number to identify it.
for($i = 0;$i ";
# get the size of a random image
$size = getimagesize($image[$r]);
$width = $size[0];
$height = $size[1];
# This is the HTML output. You can change any of this, but you should
# leave src=\"$image[$r]\" width=\"$width\" height=\"$height\" where it is.
# Remember to escape any quotation marks, etc.
$img_src = "";
# closes the directory (why keep it open?)
closedir ($dir_handle);
?>
echo $img_src; ?>
On Line Homework choose chm238 -Review Session Tuesday night at 5pm |
Bill Reusch's Virtual Textbook |
CoursePack Course Surveys |
|||||
Pushing Electron Tutorials | Practice Materials-includes old exams |
All Class Materials
Course Pack |
|||||
| Most Grades are Posted Now. | Review Guide for Final Exam from professor Pavia@wwu |