Jan 27, 2015, 8:43 AM
Uploading file using MVC
Hello
I am trying to upload a file. The form which I am using is a partial view. Here is the code:
I am trying to upload a file. The form which I am using is a partial view. Here is the code:
<form id="uploadForm" enctype="multipart/form-data">
@(
Html.X().Window()
.Title("Upload an image")
.Width(600)
.Closable(true)
.Resizable(false)
.Items(
Html.X().FormPanel().ID("uploadFormPanel").Frame(true).Width(600).Padding(10)
.Items(
Html.X().FileUploadField().ID("FileUploadField1").EmptyText("Select a file").FieldLabel("File:").ButtonText("Browse").Icon(Icon.PageWhitePut).LabelWidth(30).InputWidth(520).AllowBlank(false)
)
.Listeners(l => l.ValidityChange.Handler = "#{okButton}.setDisabled(!valid);")
)
.Buttons(
Html.X().Button()
.Text("Ok")
.ID("okButton")
.Icon(Icon.Disk)
.Disabled(true)
.DirectEvents(de =>
{
de.Click.Url = Url.Action("UploadClick");
de.Click.IsUpload = true;
de.Click.FormID = "uploadForm";
de.Click.Before = @"
if (!#{uploadFormPanel}.getForm().isValid()) {
return false;
}
Ext.Msg.wait('Uploading your photo...', 'Uploading');";
de.Click.Failure = @"
Ext.Msg.show({
title : 'Error',
msg : 'Error during uploading',
minWidth: 200,
modal : true,
icon : Ext.Msg.ERROR,
buttons : Ext.Msg.OK
});";
})
,
Html.X().Button()
.Text("Cancel")
.OnClientClick("this.up('window').close();")
)
.DefaultButton("okButton")
)
</form>
Code is actually taken from sample application, I have just added a window (I need to have a modal form for uploading a file). The problem is that HasFile property of FileUploadField is allways returning false. What should I do?