Enviar Anexos de Documentos
Bom Dia ,
Pessoa uso ha um tempo um sistema de cadastro de documentos de Leis, Decretos, Licitações, etc... e agora surgiu a necessidade de de enviar até 5 arquivos por cadastro e não estou conseguindo adaptar isso no meu script será que alguem pode me ajudar .. abaixo os códigos:
Anexos.asp
<html>
<head>
<title> WEB ADMIN </title>
<link rel="stylesheet" type="text/css" href="estilo.css">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<% If request.querystring("id")="1" then
Set Connect = Server.CreateObject("adodb.connection")
Connect.Open Dados
ComandoSQL = "SELECT * FROM Documentos order by id desc"
Set bd = Connect.Execute(ComandoSQL)
If Not bd.EOF Then
nomefoto = bd("ID")
Else
End If %>
<FORM ENCTYPE="multipart/form-data" ACTION="imagens/index3.asp?func=2&nome=<%=nomefoto%>" METHOD=POST id=form name=form>
<br><br><br><br>
<TABLE align="center" cellpadding="0" cellspacing="0" border="1" bordercolor="#000000" bgcolor="#FFFFFF" width="450" style="border-width: 0">
<TR>
<TD height="18" align="center" bgcolor="#FFFFFF" style="border-style: none; border-width: medium" bordercolor="#FFFFFF">
<font face="Arial" style="font-size: 13pt" color="#808080">ID.:<%=nomefoto%>
Documento Cadastrado com Sucesso.<br>
</font></TD>
</TR>
<TR>
<TD height="18" align="center" style="border-style: none; border-width: medium" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><font face="Tahoma"><b>
<span style="font-size: 8pt"><br>
</span>
</b><span style="font-size: 8pt">
<br>
</span></font><p><font face="Tahoma"><span style="font-size: 8pt">
<INPUT NAME=File1 SIZE=30 TYPE=file>
<BR>
<br>
<INPUT type="submit" value="Enviar Arquivo">
<BR>
<BR>
</span>
<font color="#333333" style="font-size: 8pt">Nota: Por favor seja paciente,<br>
Você não receberá nenhuma notificação
até que o arquivo seja totalmente transferido.</font><span style="font-size: 8pt"><BR>
<BR>
</span></font>
</p>
<p align="center">
<font face="Arial" style="font-size: 13pt" color="#808080">
<b>
<a href="documentos.asp" style="text-decoration: none">
<font color="#808080">Enviar novo Documento</font></a></b></font></p>
<font face="Tahoma" style="font-size: 8pt">
<BR>
</font>
</TD>
</TR>
</TABLE>
</form>
<% Else
Response.redirect "incluir.asp"
end if %>
</body>
</html>
Index3.asp
<%
'***********************************************************************
' Sistema de Notícias desenvolvido pela TemisNet
' Contatos: Temístocles Sota - ICQ 104458476
' http://www.temisnet.com.br
'***********************************************************************
response.buffer=true
Func = Request("Func")
nome= Request("nome")
if isempty(Func) Then
Func = 1
End if
Select Case Func
Case 1
response.redirect "index.asp"
Case 2
ForWriting = 2
adLongVarChar = 201
lngNumberUploaded = 0
noBytes = Request.TotalBytes
binData = Request.BinaryRead (noBytes)
Set RST = CreateObject("ADODB.Recordset")
LenBinary = LenB(binData)
if LenBinary > 0 Then
RST.Fields.Append "myBinary", adLongVarChar, LenBinary
RST.Open
RST.AddNew
RST("myBinary").AppendChunk BinData
RST.Update
strDataWhole = RST("myBinary")
End if
strBoundry = Request.ServerVariables ("HTTP_CONTENT_TYPE")
lngBoundryPos = instr(1,strBoundry,"boundary=") + 8
strBoundry = "--" & right(strBoundry,len(strBoundry)-lngBoundryPos)
lngCurrentBegin = instr(1,strDataWhole,strBoundry)
lngCurrentEnd = instr(lngCurrentBegin + 1,strDataWhole,strBoundry) - 1
Do While lngCurrentEnd > 0
strData = mid(strDataWhole,lngCurrentBegin, lngCurrentEnd - lngCurrentBegin)
strDataWhole = replace(strDataWhole,strData,"")
lngBeginFileName = instr(1,strdata,"filename=") + 10
lngEndFileName = instr(lngBeginFileName,strData,chr(34))
if lngBeginFileName = lngEndFileName and lngNumberUploaded = 0 Then
Response.Write "<H2> The following Error occured.</H2>"
Response.Write "You must Select at least one file To upload"
Response.Write "<BR><BR>Hit the back button, make the needed corrections and resubmit your information."
Response.Write "<BR><BR><INPUT type='button' onclick='history.go(-1)' value='<< Back' id='button'1 name='button'1>"
Response.End
End if
if lngBeginFileName <> lngEndFileName Then
strFilename = mid(strData,lngBeginFileName,lngEndFileName - lngBeginFileName)
tmpLng = instr(1,strFilename,"\")
Do While tmpLng > 0
PrevPos = tmpLng
tmpLng = instr(PrevPos + 1,strFilename,"\")
Loop
FileName = right(strFilename,len(strFileName) - PrevPos)
lngCT = instr(1,strData,"Content-Type:")
if lngCT > 0 Then
lngBeginPos = instr(lngCT,strData,chr(13) & chr(10)) + 4
Else
lngBeginPos = lngEndFileName
End if
lngEndPos = len(strData)
lngDataLenth = lngEndPos - lngBeginPos
strFileData = mid(strData,lngBeginPos,lngDataLenth)
Set fso = CreateObject("Scripting.FileSystemObject")
total = len(FileName)
T = inStr(1,FileName,".") -1
uin = nome & right(FileName,total - T)
Set f = fso.OpenTextFile(server.mappath(".") & "\" & uin, ForWriting, True)
f.Write strFileData
Set f = nothing
Set fso = nothing
lngNumberUploaded = lngNumberUploaded + 1
End if
lngCurrentBegin = instr(1,strDataWhole,strBoundry)lngCurrentEnd = instr(lngCurrentBegin + 1,strDataWhole,strBoundry) - 1
loop
response.redirect "atualiza3.asp?id="&nome&"&foto="&uin
End Select %>
Atualiza 3.asp
<!--#include file="config.asp"-->
<%
'***********************************************************************
' Sistema de Notícias desenvolvido pela TemisNet
' Contatos: Temístocles Sota - ICQ 104458476
' http://www.temisnet.com.br
'***********************************************************************
if session("usuario") = "" and session("senha") = "" then
response.redirect "admin.asp"
end if
ID = request.querystring("id")
foto = request.querystring("foto")
IF id = "" Then
response.redirect "index.asp"
else
Set Conexao = Server.CreateObject("ADODB.Connection")
Conexao.Open Dados
ComandoSQL = "SELECT * FROM 2015 Where Id="&ID
Set bd = Server.CreateObject("ADODB.Recordset")
bd.CursorLocation = 2
bd.CursorType = 0
bd.LockType = 3
bd.Open ComandoSQL, Conexao,,, &H0001
bd("foto") = foto
bd.UpdateBatch
bd.Requery %>
</font><!-- depois de enviado o email... -->
<script language="JavaScript">alert('Cadastro efetuado com sucesso!');
location.href='documentos.asp';</script><!--#include file="view.asp"-->
<%End If%>
Discussão (3)
Carregando comentários...