Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa Tarde,
Estou desenvolvendo um sistema que busca de arquivos de imagem. Aqui está funcionando diretinho. Mas quando eu busca a palavra por exemplo "cha", ele nao retorne nenhum arquivos no diretorio, falando que "0 encontrados", mas tem arquivo de imagem chamado cha.
Alguem sabe aruumar para mim?
Aqui esta o codigo:
arquivo 01.asp = o usuario digita a palavra
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<table cellspacing=2 cellpadding=2 border=0 align="center">
<tbody>
<tr valign=bottom align=middle>
<td width="172" bgcolor="#8CA6CE"><b><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Pesquisa:</font></b></td>
</tr>
<tr valign=top align=middle>
<td>
<table cellspacing=0 cellpadding=1 width=171 border=0 bgcolor=#8CA6CE>
<tbody>
<tr>
<td width="100%"> <font face="verdana, arial, helvetica" size=-1><small> </small></font>
<table cellspacing=0 cellpadding=4 width="100%" bgcolor=#8CA6CE border=0>
<tbody>
<tr><form action="02.asp" method="post">
<td align=left bgcolor="#FFFFFF">
<input class="formcreate" type="text" name="txtKeyWord" size="22"><input class="formcreate" type="submit" value="Ir" name="search">
</td>
</form></tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>
</html>
arquivo: 02.asp = esse retorna a busca digitada
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
'Option Explicit
Response.Buffer = True
' Configure alguns objetos FileSystem
dim objFS, objFolder, objFiles, File, FileName, objCheckFile, strSitePath
set objFS = server.CreateObject("Scripting.FileSystemObject")
dim strListofFiles, arrFileList, strPageTitle, iReturnCount
dim objFolders
strListofFiles = ""
iReturnCount = 0
' Os valores de pesquisa, espaço de pesquisa, eo valor de retorno
dim strKeyWord, strFileContents, returnValue, arrKeyWords
dim bKeyWordFound, i, j
'diretorio = request.querystring("F:\ARQUIVOS PORTAL2\Banco de Imagens Oficial")
'if diretorio = "" then
'Obter o caminho físico para o diretório atual
strSitePath = Server.MapPath(".")
'Pegue os keyworlds e dividi-los em uma matriz
strKeyWord = Trim(request("txtKeyWord"))
arrKeyWords = split(strKeyWord," ")
' obter a lista de arquivos
Set objFolder = objFS.GetFolder(strSitePath)
'Sub que pega todos os "htm." & ". Html" arquivos na pasta e dado
'Recurses através de todas as subpastas.
sub getCompleteFileList(inFolder, Path)
dim oFiles, oFolders, Folder, sPath
'obter todos os arquivos e subpastas
Set oFiles = inFolder.Files
Set oFolders = inFolder.SubFolders
' Se temos uma subpasta precisamos do caminho parcial
if (Path <> "") then
sPath = Path + "\"
end if
'Adicione cada "htm." & ". Html" arquivo à lista
For Each File in oFiles
FileName = File.Name
if((Lcase(right(FileName,4)) = ".jpeg") OR (Lcase(right(FileName,5)) = ".jpeg" )) then
if (strListofFiles = "") then
strListofFiles = sPath + FileName
else
strListofFiles = strListofFiles + "," + sPath + FileName
end if
end if
Next
' Check all the subfolders for ".htm" & ".html" files
'checa todos os subpastas dos arquivos
For Each Folder in oFolders
if (Folder.Name <> "images" AND Folder.Name <> "stats") then
call getCompleteFileList(Folder, sPath + Folder.Name)
end if
Next
' Clean up
'Limpe
set File = Nothing
set oFiles = Nothing
set Folder = Nothing
set oFolders = Nothing
end sub
%>
<html>
<head>
<title>Resultado de Busca </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table cellspacing=7 cellpadding=2 border=0 width="100%">
<tbody>
<tr>
<td valign=top align=middle>
<table cellspacing=0 width="100%" border=0>
<tbody>
<tr>
<td align=middle bgcolor=#3366cc>
<table cellspacing=0 cellpadding=2 width="100%" border=0>
<tbody>
<tr>
<td align=middle bgcolor=#ffffff>
<table cellspacing=0 width="100%" border=0>
<tbody>
<tr bgcolor="#F2F2F2">
<td align=middle colspan=4 bgcolor="#F2F2F2">
<div align="left"><b>Resultado de Busca</b></div>
</td>
</tr>
<tr bgcolor="#F2F2F2">
<td align=middle colspan=4 bgcolor="#FFFFFF">
<div align="left"></div>
<p align="left">
<!--
O início da pesquisa código html específico.
Ela precisa de um olhar e sentir atualização.
//-->
</p>
<table width="95%" border="0" cellspacing="1" cellpadding="1" align="center">
<tr bgcolor="#330099">
<td bgcolor="#FFFFFF">
<div align="left">
<font color="#FFFFFF"><b> <font color="#666666">Você procurou por: </font>
<font color="#000000"> </font></b><font color="#000000"><font color="#FF0000"><%= strKeyWord%></font></font></font></div>
</td>
</tr>
<%
'Somente na busca nós temos pelo menos uma palavra-chave
if (strKeyWord <> "") then
'Chame o sub que recebe todos os arquivos
call getCompleteFileList(objFolder, "")
'Tome a corda grande ole o contém todos os arquivos separados por vírgulas e cortá-la.
arrFileList = split(strListofFiles,",")
For i=0 to UBound(arrFileList)
'Abra o arquivo atual e ler tudo em uma única seqüência.
'Se os arquivos são enormes isso poderia comer muito ou recursos.
Set objCheckFile = objFS.OpenTextFile(strSitePath + "\" + arrFileList(i),1,false,0)
strFileContents = objCheckFile.ReadAll
' Padrão, o sinalizador de pesquisa para false.
bKeyWordFound = false
' Para cada palavra-chave digitada pesquisar o arquivo.
for j = 0 to UBound(arrKeyWords)
returnValue = InStr(1,strFileContents,arrKeyWords(j),1)
'Se o valor de retorno não é zerar a palavra-chave foi encontrada
'Definir o flage pesquisa para corte verdade e curto fora do circuito.
if (returnValue <> 0) then
bKeyWordFound = true
j = UBound(arrKeyWords)
end if
next
' Se uma palavra-chave foi encontrada incluir esse arquivo na lista.
if (bKeyWordFound) then
' Manter o controle do número de resultados e pegar o título da página para a exibição de pesquisa
iReturnCount = iReturnCount + 1
dim startChar, endChar
startChar = InStr(1,strFileContents,"<title>",1)
endChar = InStr(1,strFileContents,"</title>",1)
if (startChar = 0 OR endChar = 0 OR ((startChar + 7) > (endChar - 7))) then
%>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="2"><a href="<%= arrFileList(i) %>"><%= arrFileList(i) %></a> <%= arrFileList(i) %></font></td>
</tr>if (strPageTitle = "") then
strPageTitle = arrFileList(i)
end if
%>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="2"><a href="<%= arrFileList(i) %>"><%= strPageTitle%></a> <%= arrFileList(i) %></font></td>
</tr>' Feche o arquivo para que possamos abrir um outro.
objCheckFile.Close
Next
end if
%>
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="2" color="#999999"><%= iReturnCount%> Páginas Encontradas</font></td>
</tr>
<tr>
<td> </td>
</tr>' Limpar todos os objetos usados.
set objCheckFile = Nothing
set File = Nothing
set objFiles = Nothing
set objFolder = Nothing
set objFS = Nothing
%>
</table>
<!-- O fim da busca em html -->
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p> </p>
</body>
</html>
Espero q alguem me ajuda!
No aguardo! :)
Carregando comentários...