Ver Mensaje Individual
  #5 (permalink)  
Antiguo 26/03/2009, 12:10
Avatar de Myakire
Myakire
Colaborador
 
Fecha de Ingreso: enero-2002
Ubicación: Centro de la república
Mensajes: 8.849
Antigüedad: 23 años, 3 meses
Puntos: 146
Respuesta: Seguridad en carpetas del servidos vs campo BLOB

Bueno, salvo la mejor opinión de Muzztein lo de la carpeta fuera del servidor es para asegurarse que alguien que se sepa la ruta no pueda brincarse la aplicación, no es indispensable si implementas un archivo "genérico" ya que la ruta no saldría en la barra de direcciónes, pero por mayor seguridad mejor pregúntale a tu host si tienes la posibilidad de colocar archivos fuera, lo del doble punto para hacer referencia rutas relativas, casi seguro que lo han deshabilitado.

El punto dos, si tienes que trabajar con tu carpeta dentro de raíz del sitio ya no aplica, la idea puediera ser algo como esto:
Código ASP:
Ver original
  1. <&#37;
  2. ...... validaciones de seguridad y todo eso
  3. Response.Buffer = True
  4. Dim strFilePath, strFileSize, strFileName
  5. Const adTypeBinary = 1
  6.  
  7. vFile = Request.QueryString("Id")
  8.  
  9. ..... buscas ese ID en alguna tabla
  10.  
  11. strFilePath = rs("Path")
  12. strFileSize = rs("Size")
  13. strFileName = rs("FileName")
  14.  
  15. Response.Clear
  16.  
  17. Set objStream = Server.CreateObject("ADODB.Stream")
  18. objStream.Open
  19. objStream.Type = adTypeBinary
  20. objStream.LoadFromFile strFilePath
  21. strFileType = lcase(Right(strFileName, 4))
  22. Select Case strFileType
  23.   Case ".asf"
  24.     ContentType = "video/x-ms-asf"
  25.   Case ".avi"
  26.     ContentType = "video/avi"
  27.   Case ".txt"
  28.     ContentType = "text/plain"
  29.   Case ".doc"
  30.     ContentType = "application/msword"
  31.   Case ".zip"
  32.     ContentType = "application/zip"
  33.   Case ".xls"
  34.     ContentType = "application/vnd.ms-excel"
  35.   Case ".gif"
  36.     ContentType = "image/gif"
  37.   Case ".jpg", "jpeg"
  38.     ContentType = "image/jpeg"
  39.   Case ".wav"
  40.     ContentType = "audio/wav"
  41.   Case ".mp3"
  42.     ContentType = "audio/mpeg3"
  43.   Case ".mpg", "mpeg"
  44.     ContentType = "video/mpeg"
  45.   Case ".rtf"
  46.     ContentType = "application/rtf"
  47.   Case ".htm", "html"
  48.     ContentType = "text/html"
  49.   Case ".asp"
  50.     ContentType = "text/asp"
  51.   Case ".pdf"
  52.     ContentType = "application/pdf"
  53.   Case Else
  54.     'Handle All Other Files
  55.     ContentType = "application/octet-stream"
  56. End Select
  57. Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName
  58. Response.AddHeader "Content-Length", strFileSize
  59. Response.Charset = "UTF-8"
  60. Response.ContentType = ContentType
  61. Response.BinaryWrite objStream.Read
  62. Response.Flush
  63. objStream.Close
  64. Set objStream = Nothing
  65. %>

Saludos