You want a user to be able to upload a file to the web server for immediate processing, without having to first store the file.
Implement the solution described in Recipe 15.2 but instead of writing the file to the filesystem, use the input stream containing the uploaded file to process the data.
.aspx file, follow the steps for
.aspx file in Recipe 15.2 and then, if you like, add a control
that will show the results of the processing—for example, a
DataGrid control to display the contents of an
uploaded XML file.
In the code-behind file for the page, use the .NET language of your choice to:
Verify, in the Upload button click event handler, that the file has been uploaded—that is, that the length of the filename and the file contents are both greater than 0—and (if appropriate) that it is a valid XML file.
Load the updated data and, if you elected to include a control for
showing the contents of the uploaded file, bind the uploaded data to
the control—for example, a
Example 15-8 through Example 15-10 show the
.aspx file and
VB and C# code-behind files for an application we’ve
written to illustrate this solution. The initial output is identical
to Recipe 15.2s
example output and is shown in Figure 15-3.
This recipe demonstrates the concept of uploading files and processing them without having to store them to the local filesystem, as you might do ...