← Foro de ASP

Problemas con SimpleDownload

Hilo en el foro de ASP · 28 de Septiembre del 2002 · 0 respuestas
Juan Minolta28 de Septiembre del 2002
Pregunta
Estoy utilizando el código de simpledownload que he encontrado en las múltiples webs de ASP que he visitado. Dicho código funciona perfectamente, excepto que no llega bien al cliente web el nombre del fichero que se está descargando, con lo que no es práctico. ¿Algún gurú sabría arreglar el asunto? soy novato en ASP. Muchas gracias anticipadas

------
<%
Response.Buffer = True
Response.Clear

' set the directory that contains the files here
strFileName = Server.MapPath( "/set/path/here/" & Request.QueryString( "file" ) )

Set Sys = Server.CreateObject( "Scripting.FileSystemObject" )
Set Bin = Sys.OpenTextFile( strFileName, 1, False )
If Sys.FileExists( strFileName ) Then
' This is the importent part :-)

' Set the Filename to save as
Call Response.AddHeader( "Content-Disposition", "attachment; filename=" & strFileName )

' Make sure the browser downloads, instead of running it
Response.ContentType = "application/octet-stream"

' Send as a Binary Byte Stream
While Not Bin.AtEndOfStream
Response.BinaryWrite( ChrB( Asc( Bin.Read( 1 ) ) ) )
Wend
Else
Response.Redirect( "filenotfound.html" )
End If
Bin.Close : Set Bin = Nothing
Set Sys = Nothing
%>

-------

Juan Minolta
¿Buscas más hilos como este? Mira el foro de ASP o usa el buscador.