This is a discussion on "Files in folder." within the Classic ASP section. This forum, and the thread "Files in folder. are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Files in folder.
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Files in folder.
I need a script and I'm totally useless writing new things. Is i ask really kindly i hope that someone can help me. This is what i need. I need the script to look in a folder for img,pdf,or doc files and if there are files in the folder it takes them posts them on the web as a link with the newest file at the top. It would be nice if there was a way to restrict how many files it would list and what files i wanted it to list.
But it needs to post the files as a table which looks like this Date uploaded File name Format Size file1 file2 file3 Is there anyone that can help me with this, the idea is that I put the scriptin a asp page and build the sorrounding look and feel around it. I'd just like to THANK YOU THANK YOU right now for anyone that feels that this is somthing they could help me with,...... Cheers |
|
|
|
|||
|
|
|
|||
|
Thats great I have gotten it to work. I have 2 questions. How do i get this rstFiles.Fields("date").Value = objItem.DateCreated to only display a date and not the date and time.
And Q2 how do I get this rstFiles.Fields("size").Value = objItem.Size to display it all in Kb and not bytes. This is how I yuse it today <td class="text"><%= rstFiles.Fields("date").Value %></td> <td class="text"><%= rstFiles.Fields("size").Value %></td> Sorry for the dumb questions... Cheers |
|
|||
|
FormatDateTime(rstFiles.Fields("date").Value,2)
Cint(rstFiles.Fields("size").Value / 1024) |
|
|||
|
Thank you Thank you thank you it's all working great and everyone is happy. I can't thank you enough for what you have done for me. I have learnt so much and the help that you get here in the best ever. I'll be coming back.... Just to bad that I'm in Australia and it seems that the rest of you are on another timezone as I have to wait about one day to get a answer.
Anyway. Thanks again...:-) |
|
|||
|
Just so you can see this is the script as I use it today. I actually call this file from a include file inside one of my pages.
<% Dim strPath Dim objFSO Dim objFolder Dim objItem Dim rstFiles Const adVarChar = 200 Const adInteger = 3 Const adDate = 7 ' NOTE: As currently implemented, this needs to end with the / strPath = "./docs/2003/announcements/" ' Create our FSO Set objFSO = Server.CreateObject("Scripting.FileSystemObject") ' Get a handle on our folder Set objFolder = objFSO.GetFolder(Server.MapPath(strPath)) %> <table border="0" width="100%" cellpadding="3" cellspacing="1"> <tr> <td class="form_head">Date</td> <td class="form_head">File</td> <td class="form_head">Format</td> <td class="form_head">Size</td> </tr> <% Set rstFiles = Server.CreateObject("ADODB.Recordset") rstFiles.Fields.Append "name", adVarChar, 255 rstFiles.Fields.Append "size", adInteger rstFiles.Fields.Append "date", adDate rstFiles.Fields.Append "type", adVarChar, 255 rstFiles.Open For Each objItem In objFolder.Files rstFiles.AddNew rstFiles.Fields("name").Value = objItem.Name rstFiles.Fields("size").Value = objItem.Size rstFiles.Fields("date").Value = objItem.DateLastModified If Len(objItem.Type) > 17 Then rstFiles.Fields("type").Value = Left(objItem.Type, 14) & "" Else rstFiles.Fields("type").Value = objItem.Type End If Next 'objItem Set objItem = Nothing Set objFolder = Nothing Set objFSO = Nothing rstFiles.Sort = "date DESC" rstFiles.MoveFirst Do While Not rstFiles.EOF %> <tr> <td class="text"><%= FormatDateTime(rstFiles.Fields("date").Value,2) %></td> <td class="text">" target="_blank"><%= rstFiles.Fields("name").Value %></td> <td class="text" align="left"><%= rstFiles.Fields("type").Value %></td> <td class="text" align="right"><%= Cint(rstFiles.Fields("size").Value / 1024) %> kb</td> </tr> <% rstFiles.MoveNext Loop ' Close the ADO Recordset object rstFiles.Close Set rstFiles = Nothing %> |
![]() |
| Tags |
| files, folder |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Listing files in a folder | ismilelots | PHP Forum | 5 | Feb 15th, 2007 18:49 |
| Folder Permissions | djanim8 | Classic ASP | 0 | Nov 29th, 2006 15:03 |
| 301 folder direct help | marcogolfo | Web Page Design | 3 | Nov 14th, 2006 21:54 |
| IFrame to FTP folder | Webforumz Staff | Web Page Design | 17 | Oct 28th, 2004 12:37 |