PDA

View Full Version : How to add extra post Parameters to MultiUpload from client side or javascript



Cyberspirit
Jun 29, 2016, 12:49 PM
Html.X().MultiUpload()
.ID("MultiUpload1")
.FileDropAnywhere(true)
.FileSizeLimit("15 MB")
.FileTypes("*.*")
.FileTypesDescription("All Files")
.FileUploadLimit(20)
.FileQueueLimit(0)
.UploadUrl(Url.Action("MultiUpload"))
.Listeners(l =>
{
l.SwfUploadLoadFailed.Fn = "loadFailed";
l.FileSelected.Fn = "fileSelected";
l.FileSelectionError.Fn = "fileSelectionError";
l.UploadStart.Handler = "updateRecord(file.id, 'status', 'Sending');";
l.UploadProgress.Handler = "updateRecord(file.id, 'progress', Math.round(bytesComplete / bytesTotal));";
l.UploadComplete.Handler = "updateRecord(file.id, 'progress', 1); updateRecord(file.id, 'status', 'Uploaded');";
l.UploadAborted.Handler = "updateRecord(file.id, 'status', 'Aborted');";
l.UploadRemoved.Handler = "var store = this.up('grid').store; store.remove(store.getById(file.id));";
l.UploadError.Fn = "uploadError";
}),
Html.X().ToolbarSeparator(),
Html.X().Button()
.Text("Start Upload")
.Icon(Icon.PageGo)
.Handler("#{MultiUpload1}.startUpload();"),
Html.X().Button()
.Text("Abort")
.Icon(Icon.PageCancel)
.Handler("abortUpload"),
Html.X().Button()
.Text("Abort All")
.Icon(Icon.PageCancel)
.Handler("#{MultiUpload1}.abortAllUploads();"),
Html.X().Button()
.Text("Remove")
.Icon(Icon.PageDelete)
.Handler("removeUpload"),
Html.X().Button()
.Text("Remove All")
.Icon(Icon.PageDelete)
.Handler("#{MultiUpload1}.removeAllUploads(); selectedFiles = new Array();")



//My Code Behind

[HttpPost]
public ActionResult MultiUpload( FileUploadEventArgs e)
{
var id=X.GetCmp<TextField>("myId").Text;///returns Null

if (e.HasFile)
{
HttpPostedFile file = e.PostedFile;
Logger.LogMessage(String.Format("Adding attachment '{0}' for GeneratedDistributionId {1}", file.FileName, id));

var svc = PostalService;
bool isNewAttachment = svc.AddDocument(id, file.FileName, file.ContentType, file.InputStream.ToByteArray(), User.Identity.Name);
}
else
{
Logger.LogMessage("No file present in upload.");
}

return new DirectResult(){IsUplaod=True};
}