Jump to content
Fórum Script Brasil
  • 0

[resolvido] Erro No Upload


claytonprog

Question

Pessoal estou com problema num form de upload. É o seguinte estou tentando fazer uma alteração num cadastro com foto, quando eu seleciono uma nova foto pra fazer a alteração o upload dá erro. aqui está meu codigo:

<!-- #include file = "upload_funcoes.asp" -->
<%
' Chamando Funções, que fazem o Upload funcionar
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin

' Recuperando os Dados Digitados ----------------------

  Dim nome
  Dim telefone
  dim endereco
  dim contato
  Dim email
  Dim login
  dim senha
  Dim ID
  dim sql


id = UploadRequest.Item("id").Item("Value") //  // linha que está dando o erro
nome = UploadRequest.Item("nome").Item("Value")
endereco = UploadRequest.Item("endereco").Item("Value")
telefone = UploadRequest.Item("telefone").Item("Value")
contato = UploadRequest.Item("contato").Item("Value")
email = UploadRequest.Item("email").Item("Value")
login = UploadRequest.Item("login").Item("Value")
senha = UploadRequest.Item("senha").Item("Value")


' Tipo de arquivo que esta sendo enviado
tipo_foto = UploadRequest.Item("foto").Item("ContentType")

' Caminho completo dos arquivos enviados
caminho_foto = UploadRequest.Item("foto").Item("FileName")


' Nome dos arquivos enviados
nome_foto = Right(caminho_foto,Len(caminho_foto)-InstrRev(caminho_foto,"\"))


' Conteudo binario dos arquivos enviados
foto = UploadRequest.Item("foto").Item("Value")


' pasta onde as imagens serao guardadas
pasta = Server.MapPath("imagens/fotos_logomarca/")
nome_foto = "/"&nome_foto


' pasta + nome dos arquivos
cfoto = "fotos_logomarca" + nome_foto


' Fazendo o Upload do arquivo selecionado
if foto <> "" then
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
Set MyFile = ScriptObject.CreateTextFile(pasta & nome_foto)
For i = 1 to LenB(foto)
MyFile.Write chr(AscB(MidB(foto,i,1)))
Next
MyFile.Close
end if


' Conecta-se ao Banco de Dados
url_conexao = Server.MapPath("db/desing.mdb")
set conexao = Server.CreateObject("ADODB.Connection")
conexao.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&url_conexao 

' cadastra os dados no banco de dados

      
ComandoSQL="UPDATE tblclientes SET nome = '" & nome & "',endereco = '" & endereco & "', telefone = '" & telefone & "', contato = '" & contato & "', email = '" & email & "', login = '" & login & "', senha = '" & senha & "', logomarca = '" & cfoto & "' WHERE ID ="&ID
   
Conexao.Execute(ComandoSQL)

' Mostra Mensagem de Confirmação na Tela
Response.write "<font face=""Verdana"" size=""2""><b>Dados Cadastrados com Sucesso!!</b><br></font>"

' Redireciona após 3 segundos
response.write "<font face=""Verdana"" size=""2""><br><br><br>Você será redirecionado em 3 segundos..<br></font>"
response.write "<meta http-equiv='refresh' content='3; url=clientes_full.asp'/>"
%>

aqui está o erro :

Microsoft VBScript runtime error '800a01a8'

Object required: 'UploadRequest.Item(...)'

/painel/Upload_form_Editar_cliente.asp, line 25

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Não sei se tem alguma coisa a ver mais quando eu estou passando o id de um form para o outro é que está dando o erro: aqui está o codigo do form que chama o upload.

<table border="0" width="100%" cellspacing="1">
                    <tr>
                        <td>
                        <%
'Faço a conexão com o bd e recupero os dados
cnpath="DBQ=" & Server.MapPath("db/desing.mdb") 
DataSource = "Driver={Microsoft Access Driver (*.mdb)}; " & cnpath 

Set Conn = Server.CreateObject("ADODB.Connection") 
id = request.querystring("Id")
Conn.Open DataSource
set rs=conn.execute("SELECT * FROM tblclientes where id =" & id & " ORDER BY nome asc")

%>

                        
                        </font> 
              <form action=Upload_form_Editar_cliente.asp method="post" enctype="multipart/form-data">
                <table width="100%" border="0">
                  <tr> 
                    <td valign="top" width="40%"> 
                      <p align="right"><font size="2"><b>Nome</b></font><b><font size="2" face="Tahoma">:</font></b></td>
                    <td width="58%">
     <font size="1" face="Tahoma"> 
                      <input id=text4 name=nome style="font-family: Verdana; font-size: 10 pt; WIDTH:405; HEIGHT: 20; border-style: solid; border-width: 1" size="10" value="<%=rs("nome")%>"></font></td>
                  </tr>
                  <tr> 
                    <td valign="top" width="40%"> 
                      <p align="right"><b><font size="2" face="Tahoma">Endereço:</font></b></td>
                    <td width="58%">
     <font size="1" face="Tahoma"> 
                      <input id=text7 name=endereco style="font-family: Verdana; font-size: 10 pt; WIDTH:405; HEIGHT: 20; border-style: solid; border-width: 1" size="10" value="<%=rs("endereco")%>"></font></td>
                  </tr>
                  <tr> 
                    <td valign="top" width="40%"> 
                      <p align="right"><b><font size="2" face="Tahoma">telefones:</font></b></td>
                    <td width="58%">
     <font size="1" face="Tahoma"> 
                      <input id=text5 name=telefone style="font-family: Verdana; font-size: 10 pt; WIDTH:405; HEIGHT: 20; border-style: solid; border-width: 1" size="10" value="<%=rs("telefone")%>"></font></td>
                  </tr>
                  <tr> 
                    <td valign="top" width="40%"> 
                      <p align="right"><b><font size="2" face="Tahoma">
                        Contato:</font></b></td>
                    <td width="58%"><font size="1" face="Tahoma"> 
                      <input id=text8 name=contato style="font-family: Verdana; font-size: 10 pt; WIDTH:405; HEIGHT: 20; border-style: solid; border-width: 1" size="10" value="<%=rs("contato")%>"></font></td>
                  </tr>
                  <tr> 
                    <td valign="top" width="40%"> 
                      <p align="right"><b><font size="2" face="Tahoma">
                        E-mail:</font></b></td>
                    <td width="58%"><font size="1" face="Tahoma"> 
                      <input id=text2 name=email style="font-family: Verdana; font-size: 10 pt; WIDTH:405; HEIGHT: 20; border-style: solid; border-width: 1" size="10" value="<%=rs("email")%>"></font></td>
                  </tr>
                  <tr> 
                    <td valign="top" width="40%"> 
                      <p align="right"><b><font size="2" color="#000080">Login</font></b></td>
                    <td width="58%"><font size="1" face="Tahoma"> 
                      <input id=text6 name=login style="font-family: Verdana; font-size: 10 pt; WIDTH:404; HEIGHT: 20; border-style: solid; border-width: 1" size="10" value="<%=rs("login")%>"></font></td>
                  </tr>
                  <tr> 
                    <td valign="top" width="40%"> 
                      <p align="right"><b><font size="2" face="Tahoma">
                        <font color="#000080">Senha</font>:</font></b></td>
                    <td width="58%"><font size="1" face="Tahoma"> 
                      <input id=text3 name=senha style="font-family: Verdana; font-size: 10 pt; WIDTH:404; HEIGHT: 20; border-style: solid; border-width: 1" size="10" value="<%=rs("senha")%>"></font></td>
                  </tr>
                  <tr> 
                    <td> 
                      <p align="right"><b>
                        <font color="#000080" size="2" face="Tahoma">Logomarca:</font></b></td>
                    <td> 
                      <img src="../painel/imagens/<%=rs("logomarca")%>" border="0" align="center" hspace="8" vspace="2" width="155" height="131"></td>
                  </tr>
                  <tr> 
                    <td> 
                      &nbsp;</td>
                    <td> 
                      &nbsp;&nbsp; 
                <input type="file" name="foto" size="25"></td>
                  </tr>
                  <tr> 
                    <td colspan="2"> 
                      &nbsp;</td>
                  </tr>
                  <tr> 
                    <td colspan="2"> 
                      <div align="center"><font face="Tahoma"> 
                        <input type="hidden" name="ID" value="<%=rs("ID")%>"> // aqui eu passo o id
                        <input type="submit" value="Modificar Cliente" id=submit1 name=submit>
                        </font></div>
                    </td>
                  </tr>
                </table>
                <div align="center"></div>
              </form>
</td>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152k
    • Total Posts
      651.5k
×
×
  • Create New...