De nuevo downLoadFile

20/01/2004 - 16:37 por Mario Cassanelli | Informe spam
El codigo lo obtuve en este foro, como prodran ver no cambie nada..., o creo
que casi nada..., al final esta lo que sale
mezcla de HTML y el archivo csv, estoy buscando en el help de visual
interdev, para entender el codigo

Gracias
Saludos
Mario


<body bgcolor="#FFFFFF" text="#000000">
<%
DIM FICHERO
DIM strPATH

FICHERO = request.QUERYSTRING("nombre")
strPATH="vt_ventas"

'RESPONSE.WRITE "<br>" & fichero & "<br>" & strPATH
'RESPONSE.WRITE "<br>" & Server.Mappath(strPath & "/" & fichero)

response.contentType = "application/x-unknow"
response.addHeader "Content-Disposition","fattachment; filename=" & chr(34)
& fichero & chr(34)
response.BinaryWrite getBinaryFile( Server.Mappath(strPath & "/" &
fichero) )

function getBinaryFile(fileSpec)
Dim adTypeBinary
Dim oStream
adTypeBinary = 1
set oStream = server.createobject("ADODB.Stream")
oStream.Open
oStream.Type = adTypeBinary
oStream.LoadFromFile fileSpec
getBinaryFile = oStream.read
set oStream = Nothing
end function
%>

</body>



<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
.
.
.
22/12/2003,83,JUAN JOSE,EFECTIVO,CF , ,B -330, 23.55,21.00, 4.95,0.00,
0.00, 0.00, 0.00, 28.50,ACAZON, , , , , , , ,
22/12/2003,367,GRAICELA HILDA,EFECTIVO,CF , ,B -337, 15.70,21.00,
3.30,0.00, 0.00, 0.00, 0.00, 19.00,ACAZON, , , , , , ,
,
.
.
.


</body>
</html>
 

Leer las respuestas

#1 Miguel González
20/01/2004 - 17:38 | Informe spam
Prueba a quitarle al código los "tags" html que lo envuelven ("<html>" etc.) y no hagas el response.write de texto.

La página quedaría limpia y pelada mas o menos así:

<%
DIM FICHERO
DIM strPATH

Function getBinaryFile(fileSpec)
Dim adTypeBinary
Dim oStream
adTypeBinary = 1
set oStream = server.createobject("ADODB.Stream")
oStream.Open
oStream.Type = adTypeBinary
oStream.LoadFromFile fileSpec
getBinaryFile = oStream.read
set oStream = Nothing
End function

fichero = request.QUERYSTRING("nombre")
strPATH="vt_ventas"
response.contentType = "application/x-unknow"
response.addHeader "Content-Disposition","fattachment; filename=" & chr(34) & fichero & chr(34)
response.BinaryWrite getBinaryFile( Server.Mappath(strPath & "/" & fichero) )
%>

Saludos!
Miguel


"Mario Cassanelli" escribió en el mensaje news:eP4%
El codigo lo obtuve en este foro, como prodran ver no cambie nada..., o creo
que casi nada..., al final esta lo que sale
mezcla de HTML y el archivo csv, estoy buscando en el help de visual
interdev, para entender el codigo

Gracias
Saludos
Mario


<body bgcolor="#FFFFFF" text="#000000">
<%
DIM FICHERO
DIM strPATH

FICHERO = request.QUERYSTRING("nombre")
strPATH="vt_ventas"

'RESPONSE.WRITE "<br>" & fichero & "<br>" & strPATH
'RESPONSE.WRITE "<br>" & Server.Mappath(strPath & "/" & fichero)

response.contentType = "application/x-unknow"
response.addHeader "Content-Disposition","fattachment; filename=" & chr(34)
& fichero & chr(34)
response.BinaryWrite getBinaryFile( Server.Mappath(strPath & "/" &
fichero) )

function getBinaryFile(fileSpec)
Dim adTypeBinary
Dim oStream
adTypeBinary = 1
set oStream = server.createobject("ADODB.Stream")
oStream.Open
oStream.Type = adTypeBinary
oStream.LoadFromFile fileSpec
getBinaryFile = oStream.read
set oStream = Nothing
end function
%>

</body>



<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
.
.
.
22/12/2003,83,JUAN JOSE,EFECTIVO,CF , ,B -330, 23.55,21.00, 4.95,0.00,
0.00, 0.00, 0.00, 28.50,ACAZON, , , , , , , ,
22/12/2003,367,GRAICELA HILDA,EFECTIVO,CF , ,B -337, 15.70,21.00,
3.30,0.00, 0.00, 0.00, 0.00, 19.00,ACAZON, , , , , , ,
,
.
.
.


</body>
</html>


Preguntas similares