Mas o mesmo está apresentando um erro que estou a dois dias tentando solucionar e nao consigo.
Se alguém tiver nossão do problema por favor, ficarei grato, pois sou péssimo em Asp.
o erro apresentado é
Objeto Request erro 'ASP 0206 : 80004005'
Não é possível chamar BinaryRead
/banco/outputfile.asp, line 41
Não é possível chamar BinaryRead após usar a coleção Request.Form.
a linha do erro é
RequestBin = Request.BinaryRead(byteCount)
agradeço desde já!
ismael ghazzaoui.
Segue os arquivos
form_comunicados.asp
<!--#include file="connect2.asp"-->
<!--#include file="cache.asp"-->
<html>
<link href="fares_stylos.css" rel="stylesheet" type="text/css">
<body>
<div id="tamanho">
<form action="outputfile.asp" method="post" name="form1" target="corpo" onSubmit="return falso(this)">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="20" colspan="2" bgcolor="#239483" class="Branco"><strong><img src="images/vazio.gif" width="10" height="10">Comunicados</strong></td>
</tr>
<tr>
<td height="20" colspan="2" class="menu"><strong>Cadastrar Comunicados.</strong></td>
</tr>
<tr>
<td colspan="2" bgcolor="#239483" class="menu"><img src="images/vazio.gif" width="1" height="1"></td>
</tr>
<tr>
<td colspan="2" class="menu"><img src="images/vazio.gif" width="10" height="10"></td>
</tr>
<tr>
<td width="335" height="20" nowrap class="Azul"> Data:</td>
<td width="914" class="Azul"> </td>
</tr>
<tr>
<td nowrap class="Azul"><input name="data" type="text" class="menu" id="usg2" value="<%=FormatDateTime(Date, 2)%>" size="11" maxlength="10"></td>
<td class="Azul"> </td>
</tr>
<tr>
<td height="20" nowrap class="Azul">horario:</td>
<td class="Azul"> </td>
</tr>
<tr>
<td nowrap class="Azul"><input name="hora" type="text" class="menu" id="descricao" value="<%=FormatDateTime(Now, 4)%>" size="10" maxlength="10"></td>
<td class="Azul"> </td>
</tr>
<tr>
<td height="20" nowrap class="Azul"> Assunto:</td>
<td rowspan="3" class="Azul"> </td>
</tr>
<tr>
<td nowrap class="Azul">
<select class="menu" name="assunto" id="assunto">
<option value="0" selected>Selecione</option>
<option value="Médico Novo">Médico Novo</option>
<option value="Desligamento Médico">Desligamento Médico</option>
<option value="Informativo">Informativo</option>
</select></td>
</tr>
<tr>
<td height="20" nowrap class="Azul">Titulo:</td>
</tr>
<tr>
<td nowrap class="Azul"><input name="titulo" type="text" class="menu" id="assunto2" size="50" maxlength="50">
<br>
<br>
Imagem:<br>
<INPUT TYPE="file" NAME="blob">
<br>
<br></td>
<td class="Azul"> </td>
</tr>
<tr>
<td nowrap class="Azul">Infomações: </td>
<td class="Azul"> </td>
</tr>
<tr>
<td nowrap class="Azul"><textarea name="informacao" class="menu" cols="60" rows="8" wrap="PHYSICAL" id="informacao"></textarea></td>
<td class="Azul"> </td>
</tr>
<tr>
<td colspan="2" nowrap class="Azul"><img src="images/vazio.gif" width="10" height="10"></td>
</tr>
<tr>
<td align="right" nowrap class="Azul"> <input name="Submit2" type="image" value="Enviar" src="images/ok_azul.jpg" align="bottom" width="21" height="20">
</td>
<td class="Azul"> </td>
</tr>
<tr>
<td nowrap class="Azul"> <input name="usuario" type="hidden" id="usuario" value="<%=session("usuario")%>">
<input name="atualizacao" type="hidden" id="atualizacao" value="<%=date%> / <%=time%>"></td>
<td class="Azul"> </td>
</tr>
</table>
</form>
</div>
<script language=Javascript>
function falso(frm)
{
if(frm.data.value=="")
{
alert("O campo data não pode estar em branco!")
frm.data.focus()
return false;
}
if(frm.hora.value=="")
{
alert("O campo horario não pode estar em branco!")
frm.hora.focus()
return false;
}
if(frm.assunto.value=="0")
{
alert("É preciso colocar o assunto!")
frm.assunto.focus()
return false;
}
if(frm.titulo.value=="")
{
alert("É preciso inserir um titulo para o comunicado!")
frm.titulo.focus()
return false;
}
if(frm.informacao.value=="")
{
alert("É preciso inserir as informações para o comunicado!")
frm.informacao.focus()
return false;
}
return true;
}
</script>
<strong><font color="#009900" size="2">
<script language="JavaScript" type="text/javascript">
parent.document.getElementById("corpo").height = document.getElementById("tamanho").scrollHeight + 20; //40: Margem Superior e Inferior, somadas
</script>
</font></strong>
</body>
</html>outputfile.asp
<!--#include file="connect2.asp"-->
<!--#include file="cache.asp"-->
<html>
<html>
<head>
<title>Cadastrar Colaborador</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="fares_stylos.css" rel="stylesheet" type="text/css">
<body>
<p>
<%
Set Inserir= Server.CreateObject("Adodb.Recordset")
Inserir.open "Insert into comunicados (data, hora, assunto, titulo, informacao, blob, usuario, atualizacao) values('"&request("data")&"','"&request("hora")&"','"&request("assunto")&"','"&request("titulo")&"','"&request("informacao")&"','"&request("blob")&"','"&request("usuario")&"', '"&request("atualizacao")&"')",cn
%>
<span class="Azul">O <span class="menu"><strong> <%=request.Form("assunto")%></strong></span>
foi cadastrado com sucesso!</span> <br>
<a href="../usg/form_exame.asp" class="menu"><br>
</a><a href="javascript:history.back(1)" class="menu"><img src="images/ponto.jpg" width="5" height="5" border="0"></a>
<a href="form_comunicados.asp" target="corpo" class="menu">Cadastrar outro Comunicado.</a></p>
<p> </p>
<%
Response.Expires=0
Response.Buffer = TRUE
Response.Clear
'Response.BinaryWrite(Request.BinaryRead(Request.TotalBytes))
byteCount = Request.TotalBytes
'Response.BinaryWrite(Request.BinaryRead(varByteCount))
RequestBin = Request.BinaryRead(byteCount)
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin
contentType = UploadRequest.Item("blob").Item("ContentType")
filepathname = UploadRequest.Item("blob").Item("FileName")
filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
value = UploadRequest.Item("blob").Item("Value")
'Create FileSytemObject Component
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
'Create and Write to a File
pathEnd = Len(Server.mappath(Request.ServerVariables("PATH_INFO")))-14
Set MyFile = ScriptObject.CreateTextFile(Left(Server.mappath(Request.ServerVariables("PATH_INFO")),pathEnd)&filename)
For i = 1 to LenB(value)
MyFile.Write chr(AscB(MidB(value,i,1)))
Next
MyFile.Close
%>
<p align="center"><b>Uploaded file : </b><%=filename%><BR>
<img src="<%=filename%>">
<!--#include file="upload.asp"-->
</p>
</body>
</html>
upload.asp
<%
Sub BuildUploadRequest(RequestBin)
'Get the boundary
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)
'Get all data inside the boundaries
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
'Members variable of objects are put in a dictionary object
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Dictionary")
'Get an object name
Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
Pos = InstrB(Pos,RequestBin,getByteString("name="))
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
PosBound = InstrB(PosEnd,RequestBin,boundary)
'Test if object is of file type
If PosFile<>0 AND (PosFile<PosBound) Then
'Get Filename, content-type and content of file
PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
filename = hour(time) & minute(time) & day(date) & month(date) & year(date) & filename
'Add filename to dictionary object
UploadControl.Add "FileName", FileName
Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
'Add content-type to dictionary object
ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "ContentType",ContentType
'Get content of object
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
Else
'Get content of object
Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
End If
'Add content to dictionary object
UploadControl.Add "Value" , Value
'Add dictionary object to main dictionary
UploadRequest.Add name, UploadControl
'Loop to next object
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop
End Sub
'String to byte string conversion
Function getByteString(StringStr)
For i = 1 to Len(StringStr)
char = Mid(StringStr,i,1)
getByteString = getByteString & chrB(AscB(char))
Next
End Function
'Byte string to string conversion
Function getString(StringBin)
getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
Next
End Function
%>










