VB.NET Create an Acceptor
Listing 1. The first step to transferring a file is to create an acceptor. This code goes in the Uploader ASPX Page_Load event. The acceptor finds the filename sent from the requestor, retrieves the file data, and saves the data to the local server.
FilePath = Server.MapPath( _ "<your local server directory here>" Try ' Get the name of the file being ' uploaded - only 1 per post allowed LocalFileName = Request.Files.AllKeys(0) PostFile = Request.Files(LocalFileName) If FileName <> "" Then ' Now save it to the mapped subdirectory PostFile.SaveAs(LocalFilePath & LocalFileName) ' Send the success message to the ' posting agent lblStatus.Text = "File: " & _ PostFile.FileName & "posted successfully." Else ' Let post agent know that no file name ' was specified lblStatus.Text = _ "Error Posting File: Status=" & ex.Message End If Catch ex As Exception ' Write out the error for the posting agent ' to read lblStatus.Text = _ "Error Posting File: Status=" & ex.Message End Try