JMascioli Postado Junho 21, 2011 Denunciar Share Postado Junho 21, 2011 (editado) Pessoal, sou novato em ASP e estou tentando fazer um sistema para busca de arquivos.Caso encontre o arquivo, ele me retorna o nome com o link para o download.Até ai, ta tudo bem.Porém, quando clico no link, nada acontence.Eu preciso que o usuáio baixe esse arquivo, mas ao clicar no link que aparece, nada ocorre.Segue o código.<%Else ' We start the if statement that checks if there is a criteria... If Request.Form("Criteria") = "" Then Response.Write("<H2 align=""center"">É preciso informar a chave de acesso !</H2>") Else Dim objFolder Dim strSearchText Dim objFSO strSearchText = Request.Form("Criteria") ' We Create the FSO and Folder objects Set fso = Server.CreateObject("Scripting.FileSystemObject") Set objFSO = Server.CreateObject("Scripting.FileSystemObject") ' We define the Folder to Search Set objFolder = objFSO.GetFolder("E:\home\npa3\Web\file") Search objFolder Function Search(ByVal objFolder) Dim objSubFolder session("intMatch") = 0 'Loop through every file in the current folder For Each objFile in objFolder.Files Set objTextStream = objFSO.OpenTextFile(objFile.Path,1) 'Read the file's contents into avariable strFileContents = objTextStream.ReadAll 'if the search string is in the file, then write a link to the file If InStr(1, strFileContents, strSearchText, 1) then Response.Write("<Table Border=""0"" Cellpadding=""0"" Cellspacing=""1"" Align=""Center"" BorderColor=""#000000"" Background="""" Width=""100%""> ") & vbcrlf Response.Write(" <TR>") & vbcrlf Response.Write " <TD Width=""50%"" BGCOLOR=""" & Coloralt & """><Font Face=""Arial"" Color=""#000000""><A HREF=""file://" & objFile.Path & """>" & objFile.Name & "</A></TD><TD Width=""16%"" BGCOLOR=""" & Coloralt & """><Font Face=""Arial"" Color=""#000000"">" & objFile.datecreated & "</TD><TD Width=""16%"" BGCOLOR=""" & Coloralt & """><Font Face=""Arial"" Color=""#000000"">" & objFile.DateLastModified & "</TD><TD Width=""16%"" BGCOLOR=""" & Coloralt & """><Font Face=""Arial"" Color=""#000000"">" & formatnumber(objFile.size,0) & "kb" & "</TD>" & vbcrlf Response.Write(" </TR>")& vbcrlf Response.Write("</Table>")& vbcrlf ' This bit of code makes the colors alternate If Coloralt="ECFDFF" Then Coloralt="CEE7FF" 'This belongs to the alternative Colores Else 'This belongs to the alternative Colores Coloralt="ECFDFF" 'This belongs to the alternative Colores End If bolFileFound = True session("intMatch") = session("intMatch") + 1 End If objTextStream.Close Next 'Here's the recursion part - for each subfolder in this directory, we run the 'Search function again For Each objSubFolder in objFolder.SubFolders Search objSubFolder Next ' We close our Objects so that we do not make the server work too hard Set fso = Nothing Set objFSO = Nothing Set objFolder = Nothing Set objTextStream = Nothing End Function If session("intMatch") = 0 Then Response.Write("<Center><b>Nenhum resultado encontrado para sua busca...</b></Center>") End If End IfEnd If %>Me ajudem por favor.....Grato a todos....... Editado Junho 21, 2011 por JMascioli Citar Link para o comentário Compartilhar em outros sites More sharing options...
0 bareta Postado Junho 30, 2011 Denunciar Share Postado Junho 30, 2011 que caminho que ele ta imprimindo no link??? mude para o caminho do arquivo com http. Citar Link para o comentário Compartilhar em outros sites More sharing options...
Pergunta
JMascioli
Pessoal, sou novato em ASP e estou tentando fazer um sistema para busca de arquivos.
Caso encontre o arquivo, ele me retorna o nome com o link para o download.
Até ai, ta tudo bem.
Porém, quando clico no link, nada acontence.
Eu preciso que o usuáio baixe esse arquivo, mas ao clicar no link que aparece, nada ocorre.
Segue o código.
<%
Else
' We start the if statement that checks if there is a criteria...
If Request.Form("Criteria") = "" Then
Response.Write("<H2 align=""center"">É preciso informar a chave de acesso !</H2>")
Else
Dim objFolder
Dim strSearchText
Dim objFSO
strSearchText = Request.Form("Criteria")
' We Create the FSO and Folder objects
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' We define the Folder to Search
Set objFolder = objFSO.GetFolder("E:\home\npa3\Web\file")
Search objFolder
Function Search(ByVal objFolder)
Dim objSubFolder
session("intMatch") = 0
'Loop through every file in the current folder
For Each objFile in objFolder.Files
Set objTextStream = objFSO.OpenTextFile(objFile.Path,1)
'Read the file's contents into avariable
strFileContents = objTextStream.ReadAll
'if the search string is in the file, then write a link to the file
If InStr(1, strFileContents, strSearchText, 1) then
Response.Write("<Table Border=""0"" Cellpadding=""0"" Cellspacing=""1"" Align=""Center"" BorderColor=""#000000"" Background="""" Width=""100%""> ") & vbcrlf
Response.Write(" <TR>") & vbcrlf
Response.Write " <TD Width=""50%"" BGCOLOR=""" & Coloralt & """><Font Face=""Arial"" Color=""#000000""><A HREF=""file://" & objFile.Path & """>" & objFile.Name & "</A></TD><TD Width=""16%"" BGCOLOR=""" & Coloralt & """><Font Face=""Arial"" Color=""#000000"">" & objFile.datecreated & "</TD><TD Width=""16%"" BGCOLOR=""" & Coloralt & """><Font Face=""Arial"" Color=""#000000"">" & objFile.DateLastModified & "</TD><TD Width=""16%"" BGCOLOR=""" & Coloralt & """><Font Face=""Arial"" Color=""#000000"">" & formatnumber(objFile.size,0) & "kb" & "</TD>" & vbcrlf
Response.Write(" </TR>")& vbcrlf
Response.Write("</Table>")& vbcrlf
' This bit of code makes the colors alternate
If Coloralt="ECFDFF" Then
Coloralt="CEE7FF" 'This belongs to the alternative Colores
Else 'This belongs to the alternative Colores
Coloralt="ECFDFF" 'This belongs to the alternative Colores
End If
bolFileFound = True
session("intMatch") = session("intMatch") + 1
End If
objTextStream.Close
Next
'Here's the recursion part - for each subfolder in this directory, we run the
'Search function again
For Each objSubFolder in objFolder.SubFolders
Search objSubFolder
Next
' We close our Objects so that we do not make the server work too hard
Set fso = Nothing
Set objFSO = Nothing
Set objFolder = Nothing
Set objTextStream = Nothing
End Function
If session("intMatch") = 0 Then
Response.Write("<Center><b>Nenhum resultado encontrado para sua busca...</b></Center>")
End If
End If
End If
%>
Me ajudem por favor.....
Grato a todos.......
Editado por JMascioliLink para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.