读出文件夹内的所有图片

原创 2004年08月07日 10:44:00

读出文件夹内的所有图片,并以分页的形式显示出来,文件夹内加新图片后,自动添加
请问怎么写?或推荐个源码下载也成
谢谢! ;)

 

<script language="vbscript">Dim fso, f, f1, fc, s    Set fso = CreateObject("Scripting.FileSystemObject")    Set f = fso.GetFolder("c:/")    Set fc = f.Files    For Each f1 in fc        s = s & f1.name         s = s & "<BR>"    Next    document.write(s)</script>

文件1:
PhotoAlbum.asp
<%

' PhotoAlbum

Dim CurFile, PopFileShowSub, ShowPic, PictureNo
Dim strPathInfo, strPhysicalPath


Dim intTotPics, intPicsPerRow, intPicsPerPage, intTotPages, intPage, strPicArray()
intPicsPerRow = 4
intPicsPerPage = 4

intPage = CInt(Request.QueryString("Page"))
If intPage = 0 Then
    intPage = 1
End If


CurFile = "PhotoAlbum.asp"
PopFile = "ShowPicture.asp"
%>
<link rel="stylesheet" type="text/css" href="style.css">
<script language="JavaScript">
<!--
function jumppage(sel)
{
var i = sel.selectedIndex
self.location.href = sel.options[i].value
}
// -->
</script>
<script language="JavaScript">
<!-- hide from JavaScript-challenged browsers
function openGalleryWindow(url) {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=600;
    var xOffset = (xMax - 200)/2, yOffset = (yMax - 200)/2;
    var xOffset = 100, yOffset = 100;

    popupWin = window.open(url,'new_page','width=700,height=535,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',scrollbars=auto,toolbars=no,menubar=no,resizable=yes')
}
// done hiding -->
</script>

<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#000000" width="100%" id="AutoNumber1">
<tr>

<td align="center" width="25%">
<form action=<%=PopFile%> method="POST">
<font face="<%= strDefaultFontFace %>" size="<% =strFooterFontSize %>" color="<% =strBaseFontColor %>"><b>Photo Album:</b>
<select name="go" onChange="jumppage(this);" size=1>
<%
ShowSub = request("ShowSub")
ShowPic = request("ShowPic")
strPathInfo = Request.ServerVariables("PATH_INFO")
strPhysicalPath = Server.MapPath(strPathInfo)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPhysicalPath)
Set objFolder = objFile.ParentFolder
Set objFolderContents = objFolder.Files
For each Folder in objFolder.SubFolders
    If Left(Folder.Name,1)<>"_" Then
         Response.write "<option "
         If ShowSub=Folder.Name Then
             Response.Write "selected "
         End if
         Response.Write"value='" & CurFile & "?ShowSub="
         Response.Write(Replace(Folder.Name, " ", "%20"))
         response.write "'>"
         Response.Write(Folder.Name & "</option>")
         If ShowSub <= " " Then
          ShowSub = Folder.Name
        End if
    End if
Next
Set objFSO = Nothing
%>
</select></h3>
</form>
</td>
</tr>
</table>


<%
If ShowPic > " " then
ShowPic = Replace(ShowPic, " ", "%20")
Response.Write "<a href='JavaScript:history.go(-1)'><img src='" & ShowPic & "'><BR><BR><font face=""verdana"" size=""1""><b>返回</b></a>"
Else
%>
<table border="0" cellpadding="0" cellspacing="5" style="border-collapse: collapse" bordercolor="#000000" width="100%" id="AutoNumber1">
<tr>
<%
strPhysicalPath = Server.MapPath("./" & ShowSub)
If ShowSub > " " then
ShowSub = Replace(ShowSub, " ", "%20")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPhysicalPath)
Set objFolderContents = objFolder.Files

 

     'Get the number of pictures in the subdirectory
     intTotPics = 0
For Each objFileItem in objFolderContents
        If Ucase(Right(objFileItem.Name,4))=".GIF" OR Ucase(Right(objFileItem.Name,4))=".JPG" THEN
            intTotPics = intTotPics + 1
        End if
Next

    'Get the total number of pages in the subdirectory
    If (intTotPics/intPicsPerPage) = (int(intTotPics/intPicsPerPage)) Then
        intTotPages = int(intTotPics/intPicsPerPage)
    Else
        intTotPages = int(intTotPics/intPicsPerPage)+1
    End If
    Redim strPicArray(2,intTotPics)

    'Store picture file names in an array
    x = 0
    For Each objFileItem in objFolderContents
        If Ucase(Right(objFileItem.Name,4))=".GIF" OR Ucase(Right(objFileItem.Name,4))=".JPG" THEN
            strPicArray(0,x) = objFileItem.Name
            strPicArray(1,x) = Cstr(int(x/intPicsPerPage)+1)
            x = x + 1
        End if
    Next

    'Determine if there are multiple pages and if so, display page numbers.
    If intTotPages > 1 Then
        Response.Write "<td colspan='" & intPicsPerRow & "' align='center'><font face='Verdana,Arial' size='1'>分页:&nbsp;&nbsp;&nbsp;"
        For x = 1 to intTotPages
            If x = intPage Then
                Response.Write "</font><font face='Arial' size='2'>" & x & "</font><font face='Arial' size='1'>&nbsp;&nbsp;&nbsp;&nbsp;"
            Else
                Response.Write "<a href='PhotoAlbum.asp?Page=" & x & "&ShowSub=" & ShowSub & "'>" & x & "</a>&nbsp;&nbsp;&nbsp;&nbsp;"
            End If
        Next
        Response.Write "</font></td>"
        Response.Write "</tr><tr><td>&nbsp;</td></tr><tr>"
    End If


    For x = 0 to UBound(strPicArray,2)-1
    If CInt(strPicArray(1,x)) = intPage Then
ShowPic = Replace(strPicArray(0,x), " ", "%20")
     Response.write "<td align='center' width='25%'><a href=""Javascript:openGalleryWindow('" & PopFile & "?ShowPic=" & ShowSub & "/" & ShowPic & "')"""
     Response.write "<br>"
     Response.Write("<img src='" & ShowSub & "/" & strPicArray(0,x) & "' width=150> ")
     Response.Write("<br><font color=""" & strBaseFontColor & """><b>" & Mid(strPicArray(0,x),1,Len(strPicArray(0,x))-4) & "</b></font>")
     Response.write "</a></td>" & vbcrlf

     PictureNo = PictureNo + 1
     If PictureNo=intPicsPerRow Then
         Response.write "</tr><tr>"
         PictureNo = 0
     End if
    End If
    Next

 

Set objFSO = Nothing
End if
%>
</tr>
</table>
<%
End if
%>
</center>
</html>


'文件2 ShowPicture.asp

<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>Show Picture</title>

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Alan Chu -->
<!-- Web Site: http://homepage.hkpeoples.net -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var isNav4, isIE4;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
isNav4 = (navigator.appName == "Netscape") ? 1 : 0;
isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
}
function fitWindowSize() {
if (isNav4) {
window.innerWidth = document.layers[0].document.images[0].width;
window.innerHeight = document.layers[0].document.images[0].height;
}
if (isIE4) {
window.resizeTo(800, 600);
width = (800 - (document.body.clientWidth - document.images[0].width)) + 25;
height = (600 - (document.body.clientHeight - document.images[0].height)) + 55;
window.resizeTo(width, height);
}
}
// End -->
</script>

</head>

<BODY onLoad="fitWindowSize()">

<center>
<%
ShowPic = request("ShowPic")
ShowPic = Replace(ShowPic, " ", "%20")
Response.Write "<img src='" & ShowPic & "' border=2><BR>"
response.write "<font size='2'><a href='JavaScript:onClick= window.close()'><font color='#FFFFBE'>Close Window</font></A></font>"
%>
</center>
</body>
</html>

javascript原生移动云编程9 - 如何使用云数据库读取和保存数据

用javascript在码实云平台上,可以在云里编写原生的移动应用。移动应用必然要和数据库打交道。码实平台提供了全面的云服务,也包括了数据库的部分。云编程可以方便地用javascript对数据进行操作...
  • mash5
  • mash5
  • 2014年09月11日 06:44
  • 1208

opencv 将视频读为图片放在指定文件夹中/将指定文件夹中图片读出并合成视频 cvCreateVideoWriter试分析

 [cpp] view plaincopyprint? #include   #include   #include   #include   #include   #in...
  • ss19890125
  • ss19890125
  • 2014年05月19日 16:06
  • 1427

Android 保存图片到SQLite,读出SQLite中的图片

转自:fan.zhang 1、bitmap保存到SQLite 中 数据格式:     Java代码   db.execSQL("Create table ex...
  • qq_24531461
  • qq_24531461
  • 2016年12月27日 14:33
  • 1295

Android 保存图片到SQLite,读出SQLite中的图片

转自:http://zhangfan822.iteye.com/blog/1883118
  • yxg190221
  • yxg190221
  • 2014年04月26日 19:10
  • 500

C语言读取指定文件夹下的所有文件(各种信息)

前言:由于在做老师布置的作业过程中需要用到读取文件夹下所有文件的功能,由于之前还没有用 C 语言试过,后面还是通过各种百度之后才解决掉。在这里做个记录,以后查阅方便。分析:1、头文件: 要实现我们浏...
  • baidu_30000217
  • baidu_30000217
  • 2016年11月09日 14:12
  • 3934

Qt读入读出数据库中的图片

2.在Qt里如何把图片从数据库里面读出来,接下来的代码都是以上面的表sfood为例:QString select = “select * from sfood”; query.exec(select...
  • songshu1007
  • songshu1007
  • 2015年06月28日 23:31
  • 2317

java jdbc(三)应用实例--向数据库中存储,读取图片和文件

1.向数据库存储图片通过PreparedStatement接口的setBinaryStream()方法,将二进制信息设置为parameterIndex。setBinaryStream method: ...
  • zfireear
  • zfireear
  • 2016年04月12日 16:28
  • 369

Android 保存图片到SQLite,读出SQLite中的图片

Android 保存图片到SQLite,读出SQLite中的图片 博客分类:  Android androidsqlite存图片  1、bitmap保存到SQLite ...
  • loerier
  • loerier
  • 2015年08月30日 21:44
  • 204

Android 保存图片到SQLite,读出SQLite中的图片

1、bitmap保存到SQLite 中 数据格式:     Java代码   db.execSQL("Create table express ( _id INTEGER PR...
  • longzhongren
  • longzhongren
  • 2014年04月16日 22:05
  • 843

OpenCV遍历文件夹中所有图像

今天尝试用OpenCV遍历文件夹中所有图像,并改变其尺寸大小(resize) 搜到这种方法connect,还没有尝试。 先试了一下简单的方法,首先,因为不知道文件名,比较麻烦。 最开始得到的图像如下...
  • yang6464158
  • yang6464158
  • 2014年03月10日 10:42
  • 2655
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:读出文件夹内的所有图片
举报原因:
原因补充:

(最多只允许输入30个字)