|
-
Apr 24th, 2001, 03:02 PM
#1
Thread Starter
Hyperactive Member
Can someone translate this FSO please?
I use asp and forms all day long and I'm trying to use the FileSystemObjecct now. I have downloaded someone elses code and manipulated it in hopes of learning how to write it from scratch myself. I'm having some trouble and could use a little help translating if you can. Thanks.
Here is it code, below I have explained what I can't figure out. Thanks.
Code:
<%@ Language="VBScript" %>
<HTML>
<HEAD>
<style>
<!--
td {font-family: arial, verdana;}
a {color: #ff0000; font-size: 16px; text-decoration: none;}
a:hover {color: #000000;}
-->
</style>
</HEAD>
<BODY>
<%
Dim objFileScripting, objFolder
Dim filename, filecollection, strDirectoryPath, strURLPath
strDirectoryPath = "d:\mainweb\"
strURLPath = "http://hsdcenter/"
'get file scripting object
Set objFileScripting = CreateObject("Scripting.FileSystemObject")
'return folder object
Set objFolder = objFileScripting.GetFolder("d:\mainweb\")
'return file collection in folder
Set filecollection = objFolder.Files
'create the links
%>
<table width="530" cellpadding="5" cellspacing="0" border="1">
<tr>
<td width="180" valign="top">Testing</td>
<td width="350" valign="top">
<%
For each Filename in filecollection
filename = right(filename,len(Filename) - inStrRev(Filename, "\"))
Select Case Right(Filename,3)
Case "asp", "tml", "htm"
Response.Write("<img src='File.gif'> <a href='" & strURLPath & filename & "'>" & Filename & "</a><br>")
Case "gif", "fla", "swf", "jpg"
Response.Write("<img src='Image.gif'> <a href='" & strURLPath & filename & "'>" & Filename & "</a><br>")
Case "xls"
Response.Write("<img src='Excel.gif'> <a href='" & strURLPath & filename & "'>" & Filename & "</a><br>")
Case "exe"
Response.Write("<img src='Exe.gif'> <a href='" & strURLPath & filename & "'>" & Filename & "</a><br>")
Case "zip"
Response.Write("<img src='zip.gif'> <a href='" & strURLPath & filename & "'>" & Filename & "</a><br>")
Case Else
Response.Write("<img src='None.gif'> <a href='" & strURLPath & filename & "'>" & Filename & "</a><br>")
End Select
Next
%></td>
</tr>
<tr>
<td colspan="2" align="right"><%= strURLPath %></td>
</tr>
</table>
</BODY>
</HTML>
1. I have tried to rewrite the same thing in the left td but change it to folders instead of files and I can't get that to work.
2. I have tried to play with < input type='file'... to get an upload option on the page but I can't figure that out either.
Any help would be greatly appreciated.
Art Sapimp
If you think education is expensive, try ignorance.
-
Apr 24th, 2001, 11:34 PM
#2
Lively Member
You need a 3rd party component to do user uploads in ASP
-
Apr 25th, 2001, 09:01 AM
#3
Thread Starter
Hyperactive Member
Thank you
Thank you. Does anyone know how I can list the folders in a specific directory?
If you think education is expensive, try ignorance.
-
Apr 26th, 2001, 03:30 PM
#4
New Member
Hi
Use the Subfolders property of FSO.
In your code:
objFolder.Subfolders instead of objFolder.Files
Jan
-
Apr 26th, 2001, 04:34 PM
#5
Thread Starter
Hyperactive Member
If you think education is expensive, try ignorance.
-
Apr 26th, 2001, 05:50 PM
#6
Thread Starter
Hyperactive Member
That worked great, thanks again. I just have one more issue.
I have purchased SA Fileup which is great for uploading files through ASP. I now can browse directories and upload files, but I can't find any information on creating folders with SAFileup or FileSystemObject. Is this possible? If so, how would I make this happen?
Thanks for any help.
If you think education is expensive, try ignorance.
-
Apr 30th, 2001, 04:36 AM
#7
New Member
I haven't used the SA Fileup but you can do it with FSO.
Try the CreateFolder method, like the following code:
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CreateFolder("c:\New Folder")
set fso = Nothing
Jan
-
Apr 30th, 2001, 09:18 AM
#8
Thread Starter
Hyperactive Member
Perfect, thank you very much.
If you think education is expensive, try ignorance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|