
30/05/2005, 06:24
|
| | Fecha de Ingreso: noviembre-2004
Mensajes: 29
Antigüedad: 20 años, 4 meses Puntos: 0 | |
No se puede usar la colección Request.Form después de llamar a BinaryRead Hola a todos.
Mi problema es el siguiente.
Estoy intentando llevar un un archivo con unos campos a un registro de access y el archivo me lo envia bien pero los campos me dice que no puedo hacer un request.from de datos binarios por lo que he estado mirando se puede hacer poniendo el objeto creado para enviar el archivo pero tampoco me deja diciendome que no esta permitido el form, mi codigo es este y el campo que quiero enviar junto con el archivo es "peticion".
<!--#include file="Uploader.asp"-->
<%
Response.Buffer = True
' load object
Dim load
Set load = new Uploader
' inicializando el objeto
load.initialize
' Datos binarios del fichero
Dim fileData
fileData = load.getFileData("file")
' Nombre del fichero
Dim fileName
fileName = LCase(load.getFileName("file"))
' Path del fichero
Dim filePath
filePath = load.getFilePath("file")
' Path completo del fichero
Dim filePathComplete
filePathComplete = load.getFilePathComplete("file")
' Tamano del fichero
Dim fileSize
fileSize = load.getFileSize("file")
' Tamano traducido del fichero
Dim fileSizeTranslated
fileSizeTranslated = load.getFileSizeTranslated("file")
' Tipo de fichero
Dim contentType
contentType = load.getContentType("file")
' No. de elementos del Form
Dim countElements
countElements = load.Count
' destruimos el objeto
Set load = Nothing
%>
<html>
<head>
<title>Insertar imagen en base de datos</title>
<style>
body, input, td { font-family:verdana,arial; font-size:10pt; }
body {
background-color: #FFCC00;
}
.BOTON {
font-size: 14px;
font-weight: bold;
color: #FFFF00;
background-color: #990000;
}
.caja {
color: #000000;
background-color: #FFFFCC;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<form method="POST" name="lista" enctype="multipart/form-data" action="insert.asp">
<p align="center">
<b>Insertar documentos de los informes técnicos.</b><br>
<a href="listado.asp">Para ver los datos insertados haz clic aquí.</a>
</p>
<table width="905" border="2">
<tr>
<td width="140">
<div align="center">
<input name="Submit" type="button" class="BOTON" value="PETICION" onClick="window.open('Listado_Contrato.asp', 'clientes', 'width=400px, height=500px, top=100px, left=100px, scrollbars=yes')">
</div>
<td width="315"><div align="center"><strong>CLIENTE</strong></div></td>
<td width="426"><div align="center"><strong>NOMBRE OBRA </strong></div></td>
</tr>
<tr>
<td><input name="peticion" type="text" class="caja" id="peticion" size="20"></td>
<td>
<div align="center">
<input name="cliente" type="text" class="caja" id="cliente" size="45">
</div>
<td><div align="center">
<input name="n_obra" type="text" class="caja" id="n_obra" size="60">
</div></td>
</tr>
<tr>
<td> </td>
<td><div align="center"><strong>TIPO INFORME TÉCNICO</strong></div></td>
<td><div align="center"><strong>INSPECTOR</strong></div></td>
</tr>
<tr>
<td> </td>
<td>
<div align="center">
<select name="tipoInf" class="caja" id="tipoInf">
<option></option>
<option>D.0</option>
</select>
</div></td>
<td><input name="inspector" type="text" class="caja" id="inspector" size="40"></td>
</tr>
</table>
<p style="padding-left:220;"> <%= fileName %> datos recibidos...<br>
<%
' Subida de imágenes
' Comprobamos que realmente se ha insertado el fichero en la base de datos
If fileSize > 0 Then
Dim connStr
connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="
connStr = connStr & Server.MapPath("ficheros.mdb")
' Recordset
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "Ficheros", connStr, 2, 2
' Insertando datos
rs.AddNew
rs("NombreFichero") = fileName
rs("TamanoFichero") = fileSize
rs("DatosFichero").AppendChunk fileData
rs("TipoFichero") = contentType
rs("peticion") = request.form("peticion")
rs.Update
rs.Close
Set rs = Nothing
Response.Write "<font color=""green"">El fichero ha sido guardado correctamente..."
Response.Write "</font>"
Else
Response.Write "<font color=""brown"">No has seleccionado ningún fichero para guardar"
Response.Write "...</font>"
End If
If Err.number <> 0 Then
Response.Write "<br><font color=""red"">mmm... algo ha ido mal..."
Response.Write "</font>"
End If
%>
</p>
<table border="0" align="center">
<tr>
<td>Fichero :</td>
<td><input type="file" name="file" size="60"></td>
</tr>
<td></td>
<td><input type="submit" value="Enviar"></td>
</form>
</tr>
</table>
<table width="700" border="1" align="center">
<tr>
<td>Nombre del fichero</td><td><%= fileName %></td>
</tr><tr>
<td>Path del fichero</td><td><%= filePath %></td>
</tr><tr>
<td>Path completo del fichero</td><td><%= filePathComplete %></td>
</tr><tr>
<td>Tamaño del fichero</td><td><%= fileSize %></td>
</tr><tr>
<td>Tamaño del fichero adaptado</td><td><%= fileSizeTranslated %></td>
</tr><tr>
<td>Tipo del fichero</td><td><%= contentType %></td>
</tr><tr>
<td>Nº de elementos del Form</td><td><%= countElements %></td>
</tr>
</table><br><br>
<br>
</body>
</html>
Gracias a todos |