ASP - descargar archivos con asp

 
Vista:

descargar archivos con asp

Publicado por carlos (1 intervención) el 30/05/2005 17:00:55
hola makinas,

estoy apañando un pagina de fotos y quiero permitir que se puedan descargar al hacer click, sin necesidad de usar el botón derecho, ahora lo que hago es asociarlas a un link con la foto comprimida en zip, entonces al ir a abrirla se lanza el cuadro de guardar como automaticamente, pero me han dicho que con asp no hace falta pasar a zip, q se puede hacer desde codigo

alguien sabe?

gracias, carlos
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:descargar archivos con asp

Publicado por Esteban (508 intervenciones) el 30/05/2005 22:02:07
Estoy con algo similar:

<%
Option Explicit

'**************************************
' Name: Forced Download 2
' Description:Allows you to force a file
' to be downloaded rather then displayed w
' ithin the users browser. This can be use
' d with Word documents, Excel Spreadsheet
' s, Adobe PDF's, and other files. Script
' has been optimized to support large down
' loads and be dynamically called to downl
' oad any file (except ASP, ASPX, ASA, ASA
' X, MDB files). Also clears up some probl
' ems with currupt files users had been ha
' ving by clearing all previouse content a
' nd headers.
' By: Lewis E. Moten III
'
' Inputs:Pass the location to the file v
' ia. the query string. Download.asp?FileName=/Files/Policy.doc
'
'This code is copyrighted and has
' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=8528&lngWId=4
'for details.
'**************************************

Dim Stream
Dim Contents
Dim FileName
Dim FileExt
Const adTypeBinary = 1
FileName = Request.QueryString("FileName")
if FileName = "" Then
Response.Write "Filename Not specified."
Response.End
End if
' Make sure they are not requesting your
' code
FileExt = Mid(FileName, InStrRev(FileName, ".") + 1)
Select Case UCase(FileExt)
Case "ASP", "ASA", "ASPX", "ASAX", "MDB"
Response.Write "Protected file Not allowed."
Response.End
End Select
' Download the file
Response.Clear
Response.ContentType = "application/octet-stream"
Response.AddHeader "content-disposition", "attachment; filename=" & FileName
Set Stream = server.CreateObject("ADODB.Stream")
Stream.Type = adTypeBinary
Stream.Open

Stream.LoadFromFile Server.MapPath(FileName)
While Not Stream.EOS
Response.BinaryWrite Stream.Read(1024 * 64)
Wend
Stream.Close
Set Stream = Nothing
Response.Flush
Response.End
%>

Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Información adicional

Publicado por Esteban (508 intervenciones) el 30/05/2005 22:42:54
http://www.asptutorial.info/sscript/ContentType.asp

Los datos de la página es para reemplazar la parte de: Response.ContentType = "application/octet-stream"
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar