Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Pessoal,
Tenho um formulário na página e_produtos.asp, código abaixo:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../../Connections/con_fvsj.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse
Else
MM_IIf = ifTrue
End If
End Function
%>
<%
If (CStr(Request("MM_update")) = "ed_prod") Then
If (Not MM_abortEdit) Then
' execute the update
Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_con_fvsj_STRING
MM_editCmd.CommandText = "UPDATE produtos SET referencia = ?, produto = ?, nome_link = ?, caracteristicas = ?, prioridade = ?, tema = ?, status = ?, imagem1 = ? WHERE [Código] = ?"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 203, 1, 1073741823, Request.Form("referencia")) ' adLongVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 203, 1, 1073741823, Request.Form("produto")) ' adLongVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Request.Form("nomelink")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 203, 1, 1073741823, Request.Form("caracteristicas")) ' adLongVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 5, 1, -1, MM_IIF(Request.Form("prioridade"), Request.Form("prioridade"), null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 203, 1, 1073741823, Request.Form("tema")) ' adLongVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 203, 1, 1073741823, Request.Form("status")) ' adLongVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 203, 1, 1073741823, Request.Form("fileField")) ' adLongVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 5, 1, -1, MM_IIF(Request.Form("MM_recordId"), Request.Form("MM_recordId"), null)) ' adDouble
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "grava_imagens.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End IfSet usuario_cmd = Server.CreateObject ("ADODB.Command")
usuario_cmd.ActiveConnection = MM_con_fvsj_STRING
usuario_cmd.CommandText = "SELECT * FROM adm"
usuario_cmd.Prepared = true
Set usuario = usuario_cmd.Execute
usuario_numRows = 0
%>
<%
Dim produtos__MMColParam
produtos__MMColParam = "1"
If (Request.QueryString("Código") <> "") Then
produtos__MMColParam = Request.QueryString("Código")
End If
%>
<%
Dim produtos
Dim produtos_cmd
Dim produtos_numRows
Set produtos_cmd = Server.CreateObject ("ADODB.Command")
produtos_cmd.ActiveConnection = MM_con_fvsj_STRING
produtos_cmd.CommandText = "SELECT * FROM produtos WHERE [Código] = ?"
produtos_cmd.Prepared = true
produtos_cmd.Parameters.Append produtos_cmd.CreateParameter("param1", 5, 1, -1, produtos__MMColParam) ' adDouble
Set produtos = produtos_cmd.Execute
produtos_numRows = 0
%>
<!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">](http://www.w3.org/1999/xhtml)
<link href="../css/modelagem-adm.css" rel="stylesheet" type="text/css" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Administrativo - Produtos</title>
</head>
<body>
<table width="856" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><h2 class="top">www.velassaojoao.com.br<br />
Área Administrativa</h2></td>
</tr>
<tr>
<td bgcolor="#333333" class="topo">Usuário: <%=(usuario.Fields.Item("Nome").Value)%> </td>
</tr>
<tr>
<td bgcolor="#333333" class="topo"><a href="<%= MM_Logout %>"><img src="../imagens/x.png" alt="" width="8" height="7" border="0" />Fazer logout </a></td>
</tr>
</table>
<br />
<br />
<table width="856" border="0" align="center" cellpadding="0" cellspacing="0" class="breadcumbs">
<tr>
<td><a href="../entrada.asp">Área Administrativa</a> > Edição produtos </td>
</tr>
</table>
<br />
<br /><form ACTION="<%=MM_editAction%>" METHOD="POST" enctype="application/x-www-form-urlencoded" name="ed_prod" id="ed_prod">
<table width="860" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="25" class="tabela_produtos"> Produto cod. <%=(produtos.Fields.Item("Código").Value)%> - REF.
<input name="referencia" type="text" id="referencia" value="<%=(produtos.Fields.Item("referencia").Value)%>" size="3" /></td>
</tr>
</table>
<table width="860" border="0" align="center" cellpadding="4" cellspacing="0">
<tr>
<td width="3" height="45" bgcolor="#CCF2FF"> </td>
<td width="64" height="45" bgcolor="#CCF2FF">
Produto::</td>
<td width="384" height="45" bgcolor="#CCF2FF"><input name="produto" type="text" id="produto" value="<%=(produtos.Fields.Item("produto").Value)%>" size="80" /></td>
<td width="385" valign="top" bgcolor="#CCF2FF"><br />
<br />
<br /></td>
</tr>
<tr>
<td height="45" bgcolor="#CCF2FF"> </td>
<td height="45" bgcolor="#CCF2FF">Nome do link::</td>
<td bgcolor="#CCF2FF"><input name="nomelink" type="text" id="nomelink" value="<%=(produtos.Fields.Item("nome_link").Value)%>" size="80" /></td>
<td width="385" valign="top" bgcolor="#CCF2FF"> </td>
</tr>
<tr>
<td height="55" bgcolor="#CCF2FF"> </td>
<td height="55" bgcolor="#CCF2FF">Características::</td>
<td bgcolor="#CCF2FF"><textarea name="caracteristicas" id="caracteristicas" cols="61" rows="2"><%=(produtos.Fields.Item("caracteristicas").Value)%></textarea></td>
<td bgcolor="#CCF2FF"> </td>
</tr>
<tr>
<td height="45" bgcolor="#CCF2FF"> </td>
<td height="45" bgcolor="#CCF2FF">Prioridade::</td>
<td bgcolor="#CCF2FF"><input name="prioridade" type="text" id="prioridade" value="<%=(produtos.Fields.Item("prioridade").Value)%>" size="80" /></td>
<td bgcolor="#CCF2FF">Prioridade de exibição (1,2,3), onde 1 é mais importante!!!</td>
</tr>
<tr>
<td height="45" bgcolor="#CCF2FF"> </td>
<td height="45" bgcolor="#CCF2FF">Tema::</td>
<td bgcolor="#CCF2FF"><input name="tema" type="text" id="tema" value="<%=(produtos.Fields.Item("tema").Value)%>" size="80" /></td>
<td bgcolor="#CCF2FF"> </td>
</tr>
<tr>
<td height="45" bgcolor="#CCF2FF"> </td>
<td height="45" bgcolor="#CCF2FF">Status::</td>
<td bgcolor="#CCF2FF"><input name="status" type="text" id="status" value="<%=(produtos.Fields.Item("status").Value)%>" size="80" /></td>
<td bgcolor="#CCF2FF">Setar o status para completo!!!</td>
</tr>
<tr>
<td height="45" bgcolor="#CCF2FF"> </td>
<td bgcolor="#CCF2FF">Imagem 01::</td>
<td height="45" colspan="2" bgcolor="#CCF2FF"><img src="../../imagens/produtos/<%=(produtos.Fields.Item("imagem1").Value)%>.jpg" width="42" height="42"/>
<label>
<input type="file" name="fileField" id="fileField" />
</label></td>
</tr>
<tr>
<td height="45" bgcolor="#CCF2FF"> </td>
<td bgcolor="#CCF2FF">Imagem 02::</td>
<td height="45" colspan="2" bgcolor="#CCF2FF"><img src="../../imagens/produtos/<%=(produtos.Fields.Item("imagem2").Value)%>.jpg" width="42" height="42"/></td>
</tr>
<tr>
<td height="45" bgcolor="#CCF2FF"> </td>
<td bgcolor="#CCF2FF">Imagem Grande::</td>
<td height="45" colspan="2" bgcolor="#CCF2FF"><img src="../../imagens/produtos/<%=(produtos.Fields.Item("imgg").Value)%>.jpg" width="42" height="42"/></td>
</tr>
<tr>
<td height="45" bgcolor="#CCF2FF"> </td>
<td bgcolor="#CCF2FF"> </td>
<td height="45" colspan="2" bgcolor="#CCF2FF"><label>
<input type="submit" name="button" id="button" value="Salvar" />
</label></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="ed_prod" />
<input type="hidden" name="MM_recordId" value="<%= produtos.Fields.Item("Código").Value %>" />
</form>
</body>
</html>Vejam que a página acima é para edição e gravação, até ai tudo ok!
Grava o nome da imagem no bd, mas depois cade a imagem?????
No código já fiz tudo que aprendi lendo aqui e nada!
Tentei fazer uma gambiarra, jogando a página de redirecionamento para uma outra que teoricamente gravaria a imagem, mas nada....
Olha ae:
Dim MM_editRedirectUrl
MM_editRedirectUrl = "grava_imagens.asp"
Segue código da grava_imagens.asp
<!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">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>'a maioria dos métodos de controle, lançam uma exceção se um erro ocorre, então usaremos a expressão
' On Error Resume Next
On Error Resume Next
'cria a instância do Upload control
Set objUpload = Server.CreateObject("Dundas.Upload.2")
'Salva arquivos carregados para o disco. Note que poderíamos também salvar na memória
' Isso preenche as coleções de arquivos e de formulário.
objUpload.Save "D:/web/velassaojoao/imagens/produtos/"
'Obtém o valor de um elemento do formulário chamado txtName
strName = objUpload.Form("fileField")
'Obtém o tamanho do primeiro arquivo carregado
strSize = objUpload.Files(0).Size
'Libera os recursos.
Set objUpload = Nothing
%>
<body>
</body>
</html>
To aceitando até ajuda do pai... Chico Xavier... rsrsrsrs
Carregando comentários...