회원가입∴아이디/비번찾기
홈으로


디렉토리에 있는 이미지 파일을 읽어들여 보여주는 이미지 갤러리
15년 전
php 디렉토리 핸들러 함수로 현재 디렉토리의 파일이름을 뽑아서
배열로 저장 한 다음에 javascript변수로 다시 변환하여
이미지 네비게이션을 구현해 봤습니다.

이것저것 참고하고 짜집기 하느라 코드가 좀 지저분 합니다.
저보다 더 smart한 여러분 께서 좀 봐 주시고
좀더 깔끔한 코드로 고쳐 주셨으면 합니다.

아 좀 더 괜찮게 고치신 분은 혼자 쓰시지 말고 저에게도 좀 보여주시면
고맙겠습니다. ^^

<?
### 2001.12.11
### imgSlidev2.php
### copyleft to kindsome(kindsome@intizen.com, kindsome.net)
### 사용하실 때 출처정도만이라도 밝혀 주세요


$dir=opendir(".") ;
$count = 0 ;
while($file = readdir($dir)){
$the_type = strrchr($file, ".");
$is_picture = eregi("jpg|gif|bmp|png",$the_type);

if($file != "." and $file != ".." and $is_picture) {
$slide[$count] = $file;
$count++;
}
}
closedir($dir);

?>

<html>
<head>
<title> :: 이미지 갤러리 :: </title>

<STYLE type="text/css">

.ver9 { color:; font-family:tahoma; font-size:9pt}
.input {border:solid 1 black; font-family:Tahoma; font-size:8pt; color:white; background-color:8c8c8c; width:80px; height:18px}

</STYLE>

<script language="JavaScript">
<!--
<?
// php배열을 마지막 배열요소만 제외한 나머지를 javascript배열로 변환
print(" var imagearray = new Array(");
for ($i=0; $i < ($count-1); $i++) { print(""" . $slide[$i] . "", "); }

// 마지막 배열요소
print(""" . $slide[$count-1] . "");n");
?>

var i = 0;
var imgstring = new Array ;
var maximum = imagearray.length-1 ;
for (i=0; i < maximum; i++) {
imgstring[i] = new Image() ;
imgstring[i].src = imagearray[i] ;
}


//네비게이션 함수 시작
function gallery(){
if (i == 0){
document.gallery.previous.value=" " ;
document.img.src = imagearray[i] ;
}
}

function previmg(){
if (i != 0) {
i -- ;
document.img.src = imagearray[i] ;
document.gallery.next.value = "Next"; }
if (i == 0) {
document.gallery.previous.value=" " ;
}
}

function nextimg(){
if (i != maximum ) {
i ++ ;
document.gallery.previous.value="Previous" ;
document.img.src = imagearray[i] ;
}

if (i == maximum){
document.gallery.next.value=" ";
}
}

function firstimg(){
i = 0 ;
document.img.src = imagearray[i] ;
document.gallery.previous.value=" ";
document.gallery.next.value="Next";
}

function lastimg(){
i = maximum ;
document.img.src = imagearray[i] ;
document.gallery.next.value=" " ;
document.gallery.previous.value="Previous" ;
}




-->
</script>

</head>


<body onLoad="gallery();" bgcolor="#ffffff" topmargin="10">
<table width="100%" height="100% border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">

<table width="675" border=1 bordercolorlight=Gainsboro bordercolordark=white cellpadding=3 bgcolor=f6f6f6>
<tr>
<td width="100%" height="660" align="center" valign="middle" >
<img src = "javascript:firstimg();" name="img" border=0>
</td>
</tr>
<tr>
<td height="40" align="center" valign="middle">

<br>
<form name="gallery">
<input type=button class="input" value="Previous" name="previous" onClick="previmg();">
<input type=button class="input" value="First" name="first" onClick="firstimg();" >
<input type=button class="input" value="Last" name="last" onClick="lastimg();">
<input type=button class="input" value="Next" name="next" onClick="nextimg();">
</form>

</td>
</tr>
</table>

</td>
</tr>
</table>
추천추천 : 383 추천 목록
번호 제목
2,891
입력 필드에서 특정단어(예:#err)가 포함되었을 때 실시간 감지 및 경고창 띄우기
2,890
데이터베이스 최적화와 쿼리 효율성을 높이 검색 성능을 개선하는 방법
2,889
간단한 게시판 만들기
2,888
PHP의 php.ini 파일에서 설정할 수 있는 주요 항목들을 카테고리별로 정리
2,887
유튜브 동영상의 썸네일 이미지를 체크하여 유효한 영상이아닐때 연결된 체크박스를 자동으로 체크
2,886
이미지 URL이 유효하지 않을 때, 해당 이미지와 연결된 체크박스를 자동으로 체크
2,885
HTTPS로 접속한 사용자를 강제로 HTTP로 리디렉션 하려면
2,884
PHP에서 MP3 파일을 직접 읽고 스트리밍 하기
2,883
현재 페이지가 location.reload()에 의해 새로고침되었는지
2,882
텍스트 파일을 읽고, 각 줄의 끝에서 6글자를 삭제한 후, 결과를 새로운 파일에 저장합니다.
2,881
cURL을 사용하여 리다이렉트를 따라가 최종 URL 가져오기
2,880
[PHP] $_SERVER 환경변수
2,879
10진수 <-> 16진수 변환기 PHP소스
2,878
텍스트에 직접 그라데이션 색상을 적용하려면?
2,877
CSS를 사용하여 요소의 내용물에 따라 width를 조정하는 방법
2,876
웹서버 ip 확인
2,875
웹호스팅의 절대경로를 확인
2,874
input 입력 필드 앞뒤 공백 실시간 제거
2,873
Placeholder 포커스시 감추기
2,872
MySQL 중복된 데이터를 삭제
2,871
MySQL 중복 데이터 확인
2,870
sessionStorage.getItem 와 sessionStorage.setItem
2,869
제이쿼리 랜덤으로 배경색 변경
2,868
preg match에 관한 정규식
2,867
Stream an audio file with MediaPlayer 오디오 파일 스트리밍 하기
2,866
Audio Streaming PHP Code
2,865
PHP $ SERVER 환경 변수 정리
2,864
Vimeo (비메오) API 를 사용하여 플레이어 컨트롤하기
2,863
iframe 사용시 하단에 발생하는 공백 제거방법
2,862
아이프레임(iframe) 전체화면 가능하게 하기
목록
뮤직트로트 부산광역시 부산진구 가야동 ㅣ 개인정보취급방침ㅣ모바일버전
Copyright ⓒ musictrot All rights reserved.