Creative COW SIGN IN :: SPONSORS :: ABOUT US :: CONTACT US
ADOBE DREAMWEAVER: HomeDreamweaver ForumDreamweaver TutorialsFAQAdobe FlashWeb Design

Re: External Pictures Load

Cow Forums : Adobe Dreamweaver
FAQ   •   VIEW POSTS   •   ADD A NEW POST   •   SEARCH   •   CHANGE FORUM
Respond to this post   •   Return to posts index   •   Read entire thread


Re: External Pictures Load
by Abraham Chaffin on Dec 4, 2008 at 5:32:36 pm

If you want to use a PHP script to display your images out of a single folder - here's one that I quickly wrote for you. Let me know if you have any questions about it. Whatever you name this file should have a .php at the end of it so that the php executes properly on the web server.:



<?
////////////////////////////////////////////////////////////////
////////THIS IS A PHP GALLERY SCRIPT FOR A SINGLE FOLDER////////
///////custimize by changing the top three variables////////////
//and the bottom display values - nothing else needs to change//
////////////////////////////////////////////////////////////////

//This can also be an absolute path e.g. /var/www/yourwebsite/htdocs/images
$your_image_directory="images";
//the url of the images folder
$absolute_path_of_directory="http://www.whatever.com/images";
//whatever you name this file
$name_of_this_file="myimages.php";



//opens the directory
$dir = opendir($your_image_directory);
//will store the files in the directory
$files = array();
//looks through the folder
while(($file = readdir($dir)) !== false){
//if we found a file
if (is_file($your_image_directory."/".$file)){
//get size of the image for filtering purpose
$size=getimagesize($your_image_directory."/".$file);
//if the size of width and height is more than 1
if($size[0]>1&&$size[1]>1){
//it's an image
$is_image=1;
//or else
}else{
//it's not an image
$is_image=0;
}
//or else
}else{
//not an image
$is_image=0;
}
//if we found the file is an image
if($is_image){
//put the file in the array
$files[]=$file;
}
}
//close the directory
closedir($dir);


//first file in array
$im=0;
//checks if we have an image request
if(is_numeric($_REQUEST[im])){
//if we do make it the current image
$im=$_REQUEST[im];
}


//if the image is 0 or the first image
if(!$im){
//make the previous image the last image in the array
$prev=count($files)-1;
//or else
}else{
//make the image the previous image in the array
$prev=$im-1;
}


//if we've reached the end of the array
if($im>=(count($files)-1)){
//make the next image the first image in the array
$next=0;
//or else
}else{
//make the next image the next image in the array
$next=$im+1;
}



?>
<center>
<? // DISPLAY THE IMAGE IN AN IFRAME OR WHATEVER ?>
<iframe src="<?=$absolute_path_of_directory?>/<?=$files[$im]?>"
width="200" height="200" style="border:0px;"></iframe>
<br><br>
<? // PREVIOUS BUTTON ?>
<a href='<?=$name_of_this_file?>?im=<?=$prev?>'>[ < < Prev ]</a>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<? // NEXT BUTTON ?>
<a href='<?=$name_of_this_file?>?im=<?=$next?>'>[ Next > > ]</a>
</center>





Abraham


Respond to this post   •   Return to posts index   •   Read entire thread


Current Message Thread:




Note: If you are a registered user please click here to login before posting.

Your post will not be accepted if your name and email address are not registered in our database. Click here if you do not have an account.

Name
E-Mail Address
Subject
E-Mail me when someone responds
Just This Message   Entire Thread   None  

Message:



Note: The following are HTML characters and may cause parts of your post to disappear if not used correctly: < > &
To include any portion of the post in your response, highlight the desired text and hit the "Q" key. Read more...



Add your message signature


 


Note: By clicking "Post Direct" button above, you are agreeing to the Creative Cow's Code of Conduct.



FORUMSTUTORIALSMAGAZINETRAININGVIDEOS - REELSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

© CreativeCOW.net All rights are reserved.

[Top]