Show files in a folder and ability to select
Following on from the folder creation, i wanted to have it so the user could see the list of files in the property folder and select the file to update the link in the db.
There are a possibility of 3 image paths they can update in the db, so i designed one page to handle this, instead of 3 seperates by passing the field name from a hidden field in the form
This is what i did:
Show Files Page
<%
' File System Object
PropFolder = request("Property")
Image = Request("Image") 'db field name
Dim fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")
' "Uploaded" Folder
Dim folder
Set folder = fso.GetFolder(Server.MapPath("../images/properties/" & PropFolder))
If folder.Size > 0 Then
Response.Write "Files for Property <b>" & PropFolder & "</b>"
Response.Write "[list]"
For Each file In folder.Files
Response.Write "<li type=""circle"">"
Response.Write "<a href='updateimage.asp?Property=" & PropFolder & "&Image=" & Image & "&file="
Response.Write file.Name & "'>"
Response.Write "<b>" & file.Name
Response.Write "</b></a> "
'Response.Write "( Size: " & file.Size & " ) "
Next
Response.Write "</ul>"
Response.Write "Click a file to select it"
Else
Response.Write "[list]<li type=""circle"">No Files Uploaded.</ul>"
End If
%>
Update Image Page
<%
PropFolder = request("Property")
UpdateImage = Request("Image")
filename = Request("file")
strsql = "UPDATE Properties SET " & UpdateImage & "= '../images/properties/" & PropFolder & "/" & filename & _
"'WHERE PropertyRef like '" & PropFolder & "'"
rsuser.open strsql,conn,1,2
response.redirect("updateprop.asp?property=" & PropFolder)
%>
__________________
Cheers,
C.
Chris Ellis
Icon-Business Ltd
www.icon-business.net
[email protected]
|