Nov 20, 2012, 9:39 PM
How to access/read from uploaded file
I've looked at this example and I don't understand how the FileUploadField works. The "filepath" is just the name of the file, which doesn't seem all that helpful to me. How are you supposed to be able to access the file or do anything with it?
Eventually I would like to read from a spreadsheet, but could I get an example of reading an uploaded text file? Here is what I have to start:
View:
Eventually I would like to read from a spreadsheet, but could I get an example of reading an uploaded text file? Here is what I have to start:
View:
viewportItems.Add(Html.X().Window()
.ID("UploadWindow")
.Layout("AutoLayout")
.Items(items =>
{
items.Add(Html.X().DisplayField()
.Text("Choose the file you would like to upload:"));
items.Add(Html.X().FileUploadField()
.ID("FileUploadField"));
})
.Buttons(button =>
{
button.Add(Html.X().Button()
.ID("UploadButton")
.Text("Upload")
.DirectEvents(directEvent => {
directEvent.Click.Url = "~/Home/UploadFile";
directEvent.Click.CleanRequest = true;
directEvent.Click.Method = HttpMethod.POST;
directEvent.Click.ExtraParams.Add(new Parameter("fileLocation", "this.up('window').down('fileuploadfield').getValue()", ParameterMode.Raw));
}));
}));
Controller:public ActionResult UploadFile(string fileLocation)
{
//How to read from file?
}
Last edited by KBorkiewicz; Nov 20, 2012 at 9:52 PM.