home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / ewbv7.aspx.vb < prev    next >
Text File  |  2010-08-24  |  2KB  |  78 lines

  1. Imports System.Data
  2. Imports System.Data.Common
  3. Imports System.Xml
  4. Imports System.IO
  5. Imports System.Data.OleDb
  6.  
  7. '
  8. ' ASP.NET code-behind class (Blob View) 
  9. '
  10.  
  11. Partial Class ewbv7
  12.     Inherits AspNetMaker7_tfpssnet
  13.  
  14.     '
  15.     ' ASP.NET Page_Load event
  16.     '
  17.  
  18.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  19.         Response.Cache.SetCacheability(HttpCacheability.NoCache)
  20.         Dim tbl As String = "", fld As String = ""
  21.         Dim ft As String, fn As String, fs As Long
  22.         Dim width As Integer, height As Integer, interpolation As Integer
  23.  
  24.         ' Get resize parameters
  25.         Dim resize As Boolean = (ew_Get("resize") <> "")
  26.         If ew_Get("width") <> "" Then
  27.             width = ew_ConvertToInt(ew_Get("width"))
  28.         End If
  29.         If ew_Get("height") <> "" Then
  30.             height = ew_ConvertToInt(ew_Get("height"))
  31.         End If
  32.         If width <= 0 AndAlso height < 0 Then
  33.             width = EW_THUMBNAIL_DEFAULT_WIDTH
  34.             height = EW_THUMBNAIL_DEFAULT_HEIGHT
  35.         End If
  36.         If ew_Get("interpolation") <> "" Then
  37.             interpolation = ew_ConvertToInt(ew_Get("interpolation"))
  38.         Else
  39.             interpolation = EW_THUMBNAIL_DEFAULT_INTERPOLATION
  40.         End If
  41.  
  42.         ' Resize image from physical file
  43.         If ew_Get("fn") <> "" Then
  44.             fn = ew_Get("fn")
  45.             fn = Server.MapPath(fn)
  46.             If File.Exists(fn) AndAlso ew_CheckFileType(fn) Then
  47.                 Response.BinaryWrite(ew_ResizeFileToBinary(fn, width, height, interpolation))
  48.             End If
  49.             Response.End()
  50.  
  51.         ' Display image from Session
  52.         Else
  53.             If ew_Get("tbl") = "" OrElse ew_Get("fld") = "" Then Response.End()
  54.             tbl = ew_Get("tbl")
  55.             fld = ew_Get("fld")
  56.  
  57.             ' Get blob field    
  58.             Dim obj As cUpload = New cUpload(tbl, fld)
  59.             obj.RestoreFromSession()
  60.             Dim b As Object = obj.Value
  61.             If IsDBNull(b) OrElse b Is Nothing Then Response.End()
  62.             ft = obj.ContentType
  63.             fn = obj.FileName
  64.  
  65.             'If ft <> "" Then
  66.             '    Response.ContentType = ft
  67.             'End If
  68.             'If fn <> "" Then
  69.             '    Response.AddHeader("Content-Disposition", "attachment; filename=""" & fn & """")
  70.             'End If
  71.  
  72.             If resize Then obj.Resize(width, height, interpolation)
  73.             Response.BinaryWrite(obj.Value)
  74.             Response.End()
  75.         End If
  76.     End Sub
  77. End Class
  78.