Ver Mensaje Individual
  #89 (permalink)  
Antiguo 15/11/2005, 12:37
Avatar de Saruman
Saruman
 
Fecha de Ingreso: mayo-2003
Ubicación: Panama city, Panama, Panama
Mensajes: 1.154
Antigüedad: 20 años, 11 meses
Puntos: 5
Sonrisa Mostrar diálogo "Guardar como..." para cualquier archivo, Parte II

...Continuación...

ahora, en el archivo funciones.asp colocamos las siguientes funciones necesarias para trabajar con el script de descargas. este archivo debe ir en el root.


funciones.asp

Código:
 
<%
'Si el Archivo existe en el Servidor
Function IsFileExists(strNombre)
 Set FSO = Server.CreateObject("Scripting.FileSystemObject")
 
 if FSO.FileExists(server.MapPath(strNombre)) = true then
  IsFileExists = true
 else
  IsFileExists = false
 end if
 
 set FSO = Nothing
End Function
'File Size
Function FileSize(Path, FileName, Tipo)
 if IsFolderExists(Path) = true and IsFileExists(Path & FileName) = true then
  set FSO = Server.CreateObject("Scripting.FileSystemObject")
  set oFile = FSO.GetFile(Server.MapPath(Path & FileName))
 
  FileSize = oFile.Size
 
  select case Tipo
   case 2:
    FileSize = Round(FileSize / 1024, 2)
   case 3:
    FileSize = Round(FileSize / 1048576, 2)
   case 4:
    FileSize = FileSize & " bytes"
   case 5:
    FileSize = Round(FileSize / 1024, 2) & " KB"
   case 6:
    FileSize = Round(FileSize / 1048576, 2) & " MB"
   case 7:
    if FileSize > 0 and FileSize < 1024 then
     FileSize = FileSize & " bytes"
    elseif FileSize >= 1024 and FileSize < 1048576 then
     FileSize = Round(FileSize / 1024, 2) & " KB"
    elseif FileSize >= 1048576 then
     FileSize = Round(FileSize / 1048576, 2) & " MB"
    end if
   case else
    FileSize = FileSize
  end select
 
  set oFile = nothing
  set FSO = nothing
 else
  FileSize = 0
 end if
End Function
'Comprobar si existe folder
Function IsFolderExists(Carpeta)
 set FSO = Server.CreateObject("Scripting.FileSystemObject")
 
 if Carpeta <> "" then
  if Not FSO.FolderExists(server.mappath(Carpeta)) then
   Folder_Exist = false
  else
   Folder_Exist = true
  end if
 else
  Folder_Exist = false
 end if
 
 IsFolderExists = Folder_Exist
End Function
%>

finalmente, un archivo default para hacer la prueba

default.asp

Código:
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Mostrar diálogo "Guardar como..."</title>
</head>
<body>
<!-- #include file="funciones.asp" -->
<%
 Ruta = "/ruta_del_archivo/"
 archivo = "archivo.ext"
 
 archivo_byte = FileSize(Ruta, archivo, 1)
 archivo_link = "descargar/startdownload.asp?path=" & Server.urlEncode(server.MapPath(Ruta & archivo)) & _
 "&name=" & Server.urlEncode(archivo) & "&size=" & archivo_byte
%>
<a href="<%=(archivo_link)%>" onMouseOver="self.status='Descargar el Archivo'; return true;" onMouseOut="self.status=''; return true;"><strong>PRESIONA AQUI PARA DESCARGAR EL ARCHIVO</strong></a>
</body>
</html>

si tienes alguna pregunta, no dudes en avisarme.
espero que este script sea de ayuda para muchos

saludos
__________________
Saruman

One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.