Foros del Web » Programando para Internet » ASP Clásico »

Problema con enlace href usando response.write en ASP

Estas en el tema de Problema con enlace href usando response.write en ASP en el foro de ASP Clásico en Foros del Web. Hola amigos. luego de darme demasiadas vueltas con un temita les pido ayuda a ver si me iluminan el camino. Buceando encontre un codigo ASP ...
  #1 (permalink)  
Antiguo 13/12/2012, 15:55
 
Fecha de Ingreso: enero-2009
Mensajes: 14
Antigüedad: 15 años, 3 meses
Puntos: 0
Problema con enlace href usando response.write en ASP

Hola amigos. luego de darme demasiadas vueltas con un temita les pido ayuda a ver si me iluminan el camino.

Buceando encontre un codigo ASP para buscar archivos en un directorio de un servidor web. Corre bien y hasta ahi de pelos.

Pero una vez que encuentra los archivos buscados y los lista, los enlaces tienen el file:///z:/192.168.1.40/documentos/foto.jpg

donde el "file:///" me jode el enlace. Esto se crea haciendo un

response.write "<tr><td width='50%' valign=top><a href=""" & rs.fields("FilePath") &""" >" & rs.fields("FileName") & "</td><td width='10%' align=right valign=top>"

Aqui dejo el codigo ASP completo. Ojala me ayuden!!!


<%@LANGUAGE="VBSCRIPT"%>
<%
Response.AddHeader "Pragma", "No-Cache" 'try not to cache page
Response.CacheControl = "Private" 'try not to cache page
server.scripttimeout = 300 'script will time out after 5 minutes
%>
<html>
<head><title>Find Files Using ASP</title>
<style>
body {font:10pt Arial;background-color:papayawhip;color:antiquewhite;font-weight:bold;margin-top:0px;margin-left:0px;margin-right:0px}
A:link {color:black;text-decoration:none}
A:hover {color:red;text-decoration:underline}
A:visited {color:black;text-decoration:none}
td {color:black;border-bottom:1pt solid black;font:9pt Arial}
th {color:black;border-bottom:1pt solid black;font:9pt Arial;font-weight:bold}
</style>
</head>
<body>
<div style="background-color:tan">
<center>
Find Files<br>
<%
dim filecounter, searchtext, directory 'dimention variables
dim fcount, fsize
filecounter = 0 'initialize filecounter to zero
searchtext = Trim(request("SearchText")) 'get the querystring SearchText
directory = Trim(request("Directory")) 'get the querystring Directory
if directory = "" then directory = "c:\" 'if no directory the set to c:\
'Write the Search Form to the page
response.write "<form action='FindFiles.asp' method=get>Search For:" & _
" <input type=text name=SearchText size=20 value=" & Chr(34) & searchtext & _
Chr(34) & "> Change Directory: <input type=text name=Directory size=20 value=" & _
Chr(34) & directory & Chr(34) & "> <input style='background-color:blanchedalmond;" & _
"color:chocolate' type=submit value='Start Search'></form><br></div>"
if searchtext <> "" Then 'if there is a file to search for then search
response.write "<table border=0 width='100%'>"
response.write "<tr><th width='60%'>File Name</th><th width='10%'>File Size</th><th width='30%'>Date Modified</th></tr>"
'create the recordset object to store
'the filepath, filename, filesize and last modified date
set rs = createobject("adodb.recordset")
rs.fields.append "FilePath",200,255
rs.fields.append "FileName",200,255
rs.fields.append "FileSize",200,255
rs.fields.append "FileDate",7,255
rs.open
Recurse directory 'call the subroutine to traverse the directories
Sub Recurse(Path)
'create the file system object
Dim fso, Root, Files, Folders, File, i, FoldersArray(1000)
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set Root = fso.getfolder(Path)
Set Files = Root.Files
Set Folders = Root.SubFolders
fcount = 0 'zero out the file count variable
'traverse through the subdirectories in the current directory
For Each Folder In Folders
FoldersArray(i) = Folder.Path
i = i + 1
Next
'traverse through the files in the current folder or subfolder
For Each File In Files
'check if the search string is found
num = InStr(UCase(File.Name), UCase(searchtext))
'if it is then update the recordset and sort it
if num <> 0 then
filecounter = filecounter + 1
rs.addnew
rs.fields("FilePath") = File.Path
rs.fields("FileName") = File.Name
rs.fields("FileSize") = File.Size
rs.fields("FileDate") = File.DateLastModified
rs.update
rs.Sort = "FileName ASC"
end if
Next
'recurse through the current directory until
'all subfolders have been traversed
For i = 0 To UBound(FoldersArray)
If FoldersArray(i) <> "" Then
Recurse FoldersArray(i)
Else
Exit For
End If
Next
End Sub
'if files were found then write them to the document
If filecounter <> 0 then
filecounter = 0
do while not rs.eof
filecounter = filecounter + 1
response.write "<tr><td width='50%' valign=top><a href=""" & rs.fields("FilePath") & """>" & rs.fields("FileName") & "</td><td width='10%' align=right valign=top>"
'get the file size so we can
'assign the proper Bytes, KB or MB value
fsize = CLng(rs.fields("FileSize"))
'if less than 1 kilobyte then it's Bytes
if fsize >= 0 And fsize <= 999 then
fnumber = FormatNumber(fsize,0) & " Bytes"
end if
'if 1 KB but less then 1 MB then assign KB
if fsize >= 1000 And fsize <= 999999 then
fnumber = FormatNumber((fsize / 1000),2) & " KB"
end if
'if 1 MB or more then assign MB
if fsize >= 1000000 then
fnumber = FormatNumber((fsize / 1000000),2) & " MB"
end if
'write each file and corresponding info to the document
response.write fnumber & "</td><td width='30%' align='center'>" & rs.fields("FileDate") & "</td></tr>"
rs.movenext
loop
response.write "</table>" 'end the table
else
'no files were found
end if
end if
%>
</body>
</html>

Etiquetas: asp, enlace, href, request, server, usando
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:25.