Ver Mensaje Individual
  #5 (permalink)  
Antiguo 22/11/2005, 09:22
Lethe
 
Fecha de Ingreso: noviembre-2002
Ubicación: Caracas
Mensajes: 75
Antigüedad: 22 años, 5 meses
Puntos: 0
Hola br1, gracias por la información. Yo la adpté a mi sistema y el resultado fue el siguiente:

Código:
' -- file_programas.asp --
       
   Response.Buffer = True
   Server.ScriptTimeout=900 
   
   '---ID of the file to retrieve
   ID = Request.querystring("id") 
   ids = Split(ID,",")
   IdTitulo = ids(0)
   IdFileName = ids(1)	
         
   '---Connection String
   Dim Cnn
   Set Cnn = Server.CreateObject("ADODB.Connection")
   Cnn.Open Application("CadenaConexion") 'conexion abierta

   '---Recordset Object
   Dim rs
   Set rs = Server.CreateObject("ADODB.Recordset")
      
   '---opening connection
   rs.Open "Select * From Attachment_Programas " & _
   " Where apg_titulo = '" & IdTitulo & "' And apg_file_name = '" & IdFileName & "'", Cnn, 2, 4
	
   If Not rs.EOF Then
   	
	'---asigna a variables datos del archivo				
	strFileName = rs("apg_file_name") '--nombre del file
	strFileSize = rs("apg_file_size") '--tamaño del file
	strAttachment = rs("apg_attachment") '--contenido del file
		
	'---invoca llamada a función Download		
	DownloadFile strFileName,strFileSize,strAttachment		
					
   End If
      
   '---Cierra recordset
   rs.Close
   Set rs = Nothing
   
   '---Cierra el sistema de conexion
   Cnn.Close
   set Cnn = Nothing
Código:
'--------------------------
' Proceso Download File
'--------------------------
Function DownloadFile(strFileName,strFileSize,strAttachment)
	
Response.Clear 
			
Set objStream = Server.CreateObject("ADODB.Stream") 
objStream.Open 		
objStream.Type = 1 'Indicate binary data.
	
'---obtiene la extención del archivo
strFileType = lcase(Right(strFileName, 4))
	
'---Feel Free to Add Your Own Content-Types Here 
Select Case strFileType 
		
    Case ".asf" 
        ContentTypeFile = "video/x-ms-asf" 
	        
    Case ".avi" 
        ContentTypeFile = "video/avi" 
		        
    Case ".doc" 
        ContentTypeFile = "application/msword" 
		        
    Case ".zip" 
        ContentTypeFile = "application/zip" 
		        
    Case ".xls" 
        ContentTypeFile = "application/vnd.ms-excel" 
		        
    Case ".gif" 
        ContentTypeFile = "image/gif" 
		        
    Case ".jpg", "jpeg", "pjpeg" 
        ContentTypeFile = "image/jpeg" 
		        
    Case ".wav" 
        ContentTypeFile = "audio/wav" 
		        
    Case ".mp3" 
        ContentTypeFile = "audio/mpeg3" 
		        
    Case ".mpg", "mpeg" 
        ContentTypeFile = "video/mpeg" 
		        
    Case ".rtf" 
        ContentTypeFile = "application/rtf" 
		        
    Case ".htm", "html" 
        ContentTypeFile = "text/html" 
		        
    Case ".asp" 
        ContentTypeFile = "text/asp" 
		        
    Case ".pdf"
        ContentTypeFile = "application/pdf" 
			
    Case ".bmp"	   
        ContentTypeFile = "image/bmp" 
		        
    Case Else 
        'Handle All Other Files 
        ContentTypeFile = "application/octet-stream" 
End Select 
				
'----instrucción que permite invocar la ventana del download para archivos 
Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName 
Response.AddHeader "Content-Length", strFileSize 
				    
'---In a Perfect World, Your Client would also have UTF-8 as the default 
'---In Their Browser 
Response.Charset = "UTF-8" 
Response.ContentType = ContentTypeFile 
Response.BinaryWrite strAttachment	
		
Response.Flush 				
		
objStream.Close 		
Set objStream = Nothing	
			
end Function
El problema es que no me funciona

Cuando intento abrir o salvar el archivo éste no lo encuentra, sea binario o de texto.

El detalle está que el archivo se encuentra en una B.D. SQL Server y no en un directorio físico del servidor.

¿Cómo puedo hacer para capturar el contenido del archivo a trevés del objeto: ADODB.Stream?