Aug 19, 2014, 6:50 AM
[CLOSED] File Upload Field example
Hi Guys,
I have a couple of question related to the mvc example located at http://mvc.ext.net/#/Form_FileUploadField/Basic/, the form panel section.
I would like to implement a window with some fields and a fileUpload, the code is below:
Thanks
Best regards.
Andrea
Edit:
I was wondering if exist a "best practice" for managing file limit exceding size; editing the above code in this way:
Thanks
I have a couple of question related to the mvc example located at http://mvc.ext.net/#/Form_FileUploadField/Basic/, the form panel section.
I would like to implement a window with some fields and a fileUpload, the code is below:
@(Html.X().Window()
.ID("MediaAddWindow")
.Width(windowWidth)
.Icon(Icon.UserAdd)
.Title("Nuovo contenuto multimediale")
.Resizable(false)
.Closable(false)
.Border(true)
.Layout(LayoutType.Fit)
.CloseAction(CloseAction.Destroy)
.Modal(true)
.Items(
Html.X().FormPanel()
.ID("MediaAddFormPanel")
.MarginSpec("0 0 0 0")
.Frame(true)
.Layout(LayoutType.VBox)
.BodyPadding(5)
.Defaults(d =>
{
d.Add(new Parameter("anchor", "95%", ParameterMode.Value));
d.Add(new Parameter("msgTarget", "side", ParameterMode.Value));
})
.FieldDefaults(def =>
{
def.MsgTarget = MessageTarget.Side;
})
.Items(
field =>
{
field.Add(
Html.X().ComboBoxFor(m => m.strSelectedMediaType)
.Items(Model.listMultimediaType)
.FieldLabel("Tipologia")
.Editable(false)
.Width(componentWidth)
.LabelWidth(labelWidth));
field.Add(
Html.X().TextFieldFor(m => m.strName)
.FieldLabel("Nome")
.Width(componentWidth)
.LabelWidth(labelWidth)
.AllowBlank(false));
field.Add(
Html.X().TextAreaFor(m => m.strDescription)
.FieldLabel("Descrizione")
.Width(componentWidth)
.LabelWidth(labelWidth)
.AllowBlank(true));
field.Add(
Html.X().TextFieldFor(m => m.strAlt)
.FieldLabel("Testo alternativo")
.Width(componentWidth)
.LabelWidth(labelWidth)
.AllowBlank(true));
field.Add(
Html.X().FileUploadField()
.ID("UploadFileMediaID")
.EmptyText("Selezionare un contenuto")
.FieldLabel("Media")
.ButtonText("")
.Width(componentWidth)
.LabelWidth(labelWidth)
.Icon(Icon.ImageAdd));
}
)
.Buttons(
Html.X().Button().Text("Invia")
.DirectEvents(de =>
{
de.Click.Url = Url.Action("UploadClick", "Admin");
de.Click.IsUpload = true;
de.Click.FormID = "MediaAddFormPanel";
de.Click.Before = @"if (!#{MediaAddFormPanel}.getForm().isValid()) { return false; }
Ext.Msg.wait('Trasferimento in corso...', 'Trasferimento');";
de.Click.Failure = @"Ext.Msg.show({
title : 'Errore',
msg : 'Errore durante il trasferimento',
minWidth: 200,
modal : true,
icon : Ext.Msg.ERROR,
buttons : Ext.Msg.OK
});";
}),
Html.X().Button().Text("Chiudi").Handler("window.Hsi.adminModule().CloseAddWindow();")
)
)
)
In yours example the formpanel is wrapped with:<form id="fileUpload" enctype="multipart/form-data">
Should I Set the enctype parameter? How can I do in my code?Thanks
Best regards.
Andrea
Edit:
I was wondering if exist a "best practice" for managing file limit exceding size; editing the above code in this way:
de.Click.Failure = "failureManagement(response, result, type, action, extraParams)";
I have done some debug, in the result object I have the complete stack trace with error detail but is there a property or something else that tells the error is related to file size?Thanks
Last edited by Daniil; Aug 20, 2014 at 11:56 AM.
Reason: [CLOSED]