Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Aug 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Virtual vs Physical

    Hi guys:

    I'm so close to finishing this, but I keep on getting the error to use virtual address instead of physical. However I'm getting the actual path from a form query. So the Code is:
    Code:
    <%
    Dim strPath   
    Dim objFSO    
    Dim objFolder 
    Dim objItem   
    Dim rstFiles
    Const adVarChar = 200
    Const adInteger = 3
    Const adDate = 7
    
    strPath = Request.QueryString("path")
    Response.Write(path)
    
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    
    Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))
    %>
    So how would I fixed this problem?
    Thanks.

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Server.Mappath is expecting a path from the webroot

    e.g.
    Code:
    Server.Mappath("\")
    Server.Mappath("\data\file.asp")
    Server.Mappath("data\file.asp")
    What format is your variable in?

  • #3
    New Coder
    Join Date
    Aug 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Essentially, the variable is a path that the user can enter based on searching files from a computer. I realize that you wouldn't normally do this, I'm taking a course and this is the required assignment. So basically the user enters the path they would like to see and then the files will show up in an HTML table. Does that help you?

    Thanks for your input,

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Response.Write the path. What is it?

  • #5
    New Coder
    Join Date
    Aug 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry, I'm not sure what you mean, but this is the remaining code after that first one.
    Code:
    <html>
    <head>
    <title>Show Directory</title>
    </head>
    <body>
    Contents of <strong><%= strPath %></strong><br />
    
    <br />
    
    <table border="5" bordercolor="green" cellspacing="0" cellpadding="2">
    	<tr bgcolor="#006600">
    		<td><font color="#FFFFFF"><b>File Name:</b></font></td>
    		<td><font color="#FFFFFF"><b>File Size (bytes):</b></font></td>
    		<td><font color="#FFFFFF"><b>Date Created:</b></font></td>
    		<td><font color="#FFFFFF"><b>File Type:</b></font></td>
    	</tr>
    <%
    For Each objItem In objFolder.SubFolders
    	If InStr(1, objItem, "_vti", 1) = 0 Then
    	%>
    	<tr bgcolor="#CCFFCC">
    		<td align="left" ><a href="<%= strPath & objItem.Name %>"><%= objItem.Name %></a>&nbsp;</td>
    		<td align="right"><%= objItem.DateCreated %>&nbsp;</td>
    		<td align="left" ><%= objItem.DateLastModified %>&nbsp;</td>
    		<td align="left" ><%= objItem.DateLastAccessed %>&nbsp;</td>
    	</tr>
    	<%
    	End If
    Next 
    Set rstFiles = Server.CreateObject("ADODB.Recordset")
    rstFiles.Fields.Append "name", adVarChar, 255
    rstFiles.Fields.Append "date", adInteger
    rstFiles.Fields.Append "mod", adDate
    rstFiles.Fields.Append "access", adVarChar, 255
    rstFiles.Open
    
    For Each objItem In objFolder.Files
    	rstFiles.AddNew
    	rstFiles.Fields("name").Value = objItem.Name
    	rstFiles.Fields("date").Value = objItem.DateCreated
    	rstFiles.Fields("mod").Value = objItem.DateLastModified
    	rstFiles.Fields("access").Value = objItem.DateLastAccessed
    Next 
    
    Set objItem = Nothing
    Set objFolder = Nothing
    Set objFSO = Nothing
    
    rstFiles.Sort = "size ASC, date DESC"
    
    rstFiles.MoveFirst
    
    Do While Not rstFiles.EOF
    	%>
    	<tr bgcolor="#CCFFCC">
    		<td align="left" ><a href="<%= strPath & rstFiles.Fields("name").Value %>"><%= rstFiles.Fields("name").Value %></a>&nbsp;</td>
    		<td align="right"><%= rstFiles.Fields("size").Value %>&nbsp;</td>
    		<td align="left" ><%= rstFiles.Fields("date").Value %>&nbsp;</td>
    		<td align="left" ><%= rstFiles.Fields("type").Value %>&nbsp;</td>
    	</tr>
    	<%
    	rstFiles.MoveNext
    Loop
    
    rstFiles.Close
    Set rstFiles = Nothing
    %>
    </table>
    </body>
    </html>

  • #6
    New Coder
    Join Date
    Mar 2005
    Posts
    50
    Thanks
    0
    Thanked 2 Times in 2 Posts
    i think what degsy is asking is:

    in your code just after you assign a value to
    Code:
    strPath
    you write it to the output.

    Code:
    response.write strPath
    what does is say?
    is it what you expect?
    is it really a valid path?
    see the munki click- was that so random?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •