Dim _file As New System.IO.FileStream(strFile, IO.FileMode.Open)
Dim context(_file.Length - 1) As Byte
_file.Read(context, 0, _file.Length)
Response.AddHeader("Content-Length", context.Length.ToString())
' Write the HTML back to the browser.
Response.BinaryWrite(context)
_file.Close()
Try
File.Delete(strFile)
Catch err As Exception
Dim i As String = err.Message
End Try
UPLOAD.aspx.vb:
Public Class UPLOAD
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
Protected WithEvents LinkButton1 As System.Web.UI.WebControls.LinkButton
Protected WithEvents File1 As System.Web.UI.HtmlControls.HtmlInputFile
Protected WithEvents File2 As System.Web.UI.HtmlControls.HtmlInputFile
Protected WithEvents File3 As System.Web.UI.HtmlControls.HtmlInputFile
Protected WithEvents File4 As System.Web.UI.HtmlControls.HtmlInputFile
Protected WithEvents File5 As System.Web.UI.HtmlControls.HtmlInputFile
#End Region
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If (Me.IsPostBack) Then Me.SaveImages()
End Sub
Private Function SaveImages() As System.Boolean
'//loop through the files uploaded
Dim _files As System.Web.HttpFileCollection = System.Web.HttpContext.Current.Request.Files
'//Message to the user
Dim _message As New System.Text.StringBuilder("Files Uploaded:<br>")
Dim _iFile As System.Int32
Try
For _iFile = 0 To _files.Count - 1
'// Check to make sure the uploaded file is a jpg or gif
Dim _postedFile As System.Web.HttpPostedFile = _files(_iFile)
Dim _fileName, _fileExtension As System.String