here's some
i just whipped this out from another similar script i use, so this is untested, but it should work, set your connection string, put this in the folder to get the file names from, and view in browser
<%@ Language=VBScript %>
<%
Response.Expires = -1
Server.ScriptTimeout = 400
'What dir we in?
strURLPath = Left( Request.ServerVariables("PATH_INFO"), _
InstrRev( Request.ServerVariables("PATH_INFO") , "/" ) )
Set fs = CreateObject("Scripting.FileSystemObject")
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open <<your connection string>>
%>
<html>
<head>
</head>
<body>
<h2>Adding to DB</h2>
<br>
<% AddFileNames( strURLPath ) %>
<br>
</body>
</html>
<%
Sub AddFileNames(folderspec)
Dim f, strFile, fc, s, sFileName
Set f = fs.GetFolder( Server.MapPath( folderspec ) )
Set fc = f.Files
For Each strFile in fc
sFileName = strFile.name
if (Lcase( Right( sFileName, 4 ) ) = ".jpg") or (Lcase( Right( sFileName, 4 ) ) = ".gif") then
Response.Write sFileName & " added...<br>"
strSQL = "INSERT INTO ImageTable ( ImageLocation ) VALUES ( '" & folderspec & sFileName & "' )"
objConn.Execute strSQL
end if
Next
End Sub
%>
Edited by - MorningZ on 31 August 2001 21:37:27