ASP.Net Stream I/O - via file upload

Go To StackoverFlow.com

1

I have a ASP.net webform with a file upload requirement whereby end users upload an Excel file (might be .csv) to the web server which then populates a series of Textboxes via an AJAX style postback. (page uses a Telerik RadAjaxManager / VB asp.net 3.0)

When you upload a file to the server from a web page does it show up on the server as a memory streamor file stream? How to you load this stream (as string(s)) it into an ADO Datatable?

Here is where I am have some difficulty in the concept and coding.

  1. Is the uploaded file a Memory Stream or will I need to store it in a Tmp directory on the server so that I can read it? I would rather not create any tmp files (unless they are disposed of my server auto-magically).

  2. How do I go from Stream in to String that I can split on a comma?

2012-04-05 17:28
by Dowda
The file will come over as a Stream and read from memory or saved to disk. You can't upload files via AJAX but there are some jQuery plugins that can use an iframe to upload a file hidden and then let you use AJAX. http://github.com/valums/file-uploader comes to min - Nick Bork 2012-04-05 17:33


0

I have had good luck with telerik's RadAsyncUpload - Telerik RadAsyncUploadDemos - it works with an Ajax call, so you do not have to disable ajax when uploading.

It will upload the files to a stream until you postback. You can then access them by using the UploadedFiles property. You can optionally specify a folder location via the TargetFolder property and it will copy the files to that location upon successful upload and postback.

You can use the OnFileUpload event to handle the uploaded file and then parse it out as well as described in this help article - RadControls for ASP.NET AJAX Documentation - OnFileUploaded

2012-04-05 21:14
by KRichardson
Ads