Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Help with files

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!
Before posting, make sure you have read this topic!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
Rbrtpch Posted - 16 November 2010 : 22:12:03
OK,
I am wondering if anyone can help me in doing this
I have 3 folders: miscelaneous, travel & family
each folder contains x number of pics either in jpg or gif

Now from time to time users may add a new pic
what I want to do is display the las 5 recents pics from out of the three folders.

how can I do this?
the way I do is display the folder as link and then once clicked display the pictures which is not elegant.
Any ideas?

thank you!
5   L A T E S T    R E P L I E S    (Newest First)
Carefree Posted - 18 November 2010 : 21:10:28
Good enough. Glad I could help.
Rbrtpch Posted - 18 November 2010 : 20:31:57
YOU ARE DA MAN!!!!!!!!
I got an error
Microsoft VBScript runtime error '800a01a8'
Object required, line 85


Then I comment out
from:
rsFSO.close
Set rsFSO = Nothing
objFSO.Close
set objFSO = Nothing

to:
rsFSO.close
Set rsFSO = Nothing
'objFSO.Close
set objFSO = Nothing


And looks like a charm :)
thank you! BTW yes the prerequisite is well taken :)
Carefree Posted - 18 November 2010 : 08:14:22
I threw that all out lol.

Prerequisites: you can have only images in the subfolders (the program doesn't include a file-type regex), and I left it only one level deep. If you need it to be recursive (folders within subfolders, etc.), it'll need a bit more code.

Here you go:


<%
Dim rsFSO, objFSO, objFolder, File, strFolder
strFolder = "album"
strFold = "album"
FolderList

Sub Output
	Response.Write	"<table align=""center"" width=""50%""><tr valign=""middle"">"
	i = 0
	Do while Not rsFSO.EOF
		Response.Write	"		<td align=""center"" width=""20%""><a href=""" & strFold & "/" & rsFSO("Name") & """><img src=""" & strFold & "/" & rsFSO("Name") & """ height=""100"" width=""100""></a></td>"
		i=i+1
		if i=5 then exit do
		rsFso.MoveNext
	Loop
End Sub

Function FolderList
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	Set objFolder = objFSO.GetFolder(Server.Mappath(strFolder))
	Set colSubfolders = objFolder.Subfolders
	For Each objSubfolder in colSubfolders
 		strFold = strFolder & "\" & objSubfolder.Name
		FileSorter
		Call Output
	Next
End Function

Function FileSorter
	Const adInteger = 3
	Const adDate = 7
	Const adVarChar = 200
	Set rsFSO = Server.CreateObject("ADODB.Recordset")
	Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
	Set objFolder = objFSO.GetFolder(Server.Mappath(strFold))
	Set objFSO = Nothing
	With rsFSO.Fields
		.Append "Name", adVarChar, 200
		.Append "Type", adVarChar, 200
		.Append "DateCreated", adDate
		.Append "DateLastAccessed", adDate
		.Append "DateLastModified", adDate
		.Append "Size", adInteger
		.Append "TotalFileCount", adInteger
	End With
	rsFSO.Open
	For Each File In objFolder.Files
		If (Left(File.Name, 1)) <> "_" Then 
			rsFSO.AddNew
			rsFSO("Name") = File.Name
			rsFSO("Type") = File.Type
			rsFSO("DateCreated") = File.DateCreated
			rsFSO("DateLastAccessed") = File.DateLastAccessed
			rsFSO("DateLastModified") = File.DateLastModified
			rsFSO("Size") = File.Size
			rsFSO.Update
		End If
	Next
	rsFSO.Sort = "DateCreated DESC "
	Set objFolder = Nothing
	rsFSO.MoveFirst
	Set fsoFiles = rsFSO
End Function

rsFSO.close
Set rsFSO = Nothing
objFSO.Close
set objFSO = Nothing
%>
Rbrtpch Posted - 17 November 2010 : 12:04:39
OK,
I got the code but is throwing a message indicating that a folder does not exists,
I cleaned the code a bit ( believe me was messy like hell)
any help is welcome

<%
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.CursorLocation = 3 ' adUseClient
objRS.Fields.Append "Name", 200, 50 ' adVarChar
objRS.Fields.Append "created", 7 ' adDate
objRS.Open

'This script creates an image gallery using the FileSystemObject
'See the attached help file for more details

'The directory where you folders are at
'This is all you need to change for this script to work
'*******************************************************
'imagespath = "C:\inetpub\wwwroot\image\"
imagespath =server.mappath(".\album\")
'*******************************************************



Dim FSObj, FOlderObj, FileCollObj
Set FSObj = Server.CreateObject("Scripting.FileSystemObject")
if request.querystring("gallery") = "" then
Set FolderObj = FSObj.GetFolder(imagespath)
Set FolderCollObj = FolderObj.SubFolders
For Each item in FolderCollObj
Set SubFolderObj = FSObj.GetFolder(FolderObj & "/" & item.name)
objRS.AddNew
objRS("Name") = item.name
objRS("created") = SubFolderObj.DateCreated
'response.write "<a href=""gallery_info.asp?gallery=" & item.name & """>" & item.name & "</a><br><br>"
Next
objRS.Sort = "created DESC"
objRS.MoveFirst

Dim carpetas

Do UNTIL objRS.EOF
carpetas=""
'*** do not display the link for ths subfolders
'response.write "<a href=""gallery_info.asp?gallery=" & objRS(0) & """>"
'response.write objRS(0) & " <BR><BR></A>"
carpetas =objRS(0)

response.write "<table align=""center"" width=""50%""> <tr>"


Set FolderObj = FSObj.GetFolder(imagespath &"\" & carpetas & "")
Set FileCollObj = FolderObj.Files
For each item in FileCollObj
If x = 2 Then
response.write "<TR>"
End If
imagespath ="album/"
response.write "<td><a href=""" & imagespath & carpetas & "/" & item.name & """><img src=""" & imagespath & carpetas & "/" & item.name & """ height=""100"" width=""100""></a></td>"
x = x + 1
response.write "</TR></TABLE>"
Next
objRS.movenext
Loop
'**********************************end of going into the subfolders

end if
%>
Carefree Posted - 17 November 2010 : 03:33:22
Easy enough if you'll provide a link to that page in .txt format for us to look at.

Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000 Version 3.4.07