I needed to pas an id to the async upload control. i'm using MVC, c# and razor engine.
Solution:
All that's needed it to define a function for the upload event and modify the "data" payload.
Now on the server side i got my id to associate the file on the DB.
HTML:
<div>
<input name="files" id="files" type="file" />
</div>
JScript:
$("#files").kendoUpload({
async: {
saveUrl: '@Url.Action("Save", "Codes")',
removeUrl: '@Url.Action("Remove", "Codes")',
autoUpload: true
},
upload: function (e) {
e.data = { codeID: $("#id").val() };
}
});
Controller:
[HttpPost]
public ActionResult Save(IEnumerable<HttpPostedFileBase> files, Guid codeID)
{
// The Name of the Upload component is "attachments"
foreach (var file in files)
{
// Some browsers send file names with full path. This needs to be stripped.
var fileName = Path.GetFileName(file.FileName);
var physicalPath = Path.Combine(Server.MapPath("~/Content/files"), fileName);
file.SaveAs(physicalPath);
}
// Return an empty string to signify success
return Content("");
}
Solution:
All that's needed it to define a function for the upload event and modify the "data" payload.
Now on the server side i got my id to associate the file on the DB.
HTML:
<div>
<input name="files" id="files" type="file" />
</div>
JScript:
$("#files").kendoUpload({
async: {
saveUrl: '@Url.Action("Save", "Codes")',
removeUrl: '@Url.Action("Remove", "Codes")',
autoUpload: true
},
upload: function (e) {
e.data = { codeID: $("#id").val() };
}
});
Controller:
[HttpPost]
public ActionResult Save(IEnumerable<HttpPostedFileBase> files, Guid codeID)
{
// The Name of the Upload component is "attachments"
foreach (var file in files)
{
// Some browsers send file names with full path. This needs to be stripped.
var fileName = Path.GetFileName(file.FileName);
var physicalPath = Path.Combine(Server.MapPath("~/Content/files"), fileName);
file.SaveAs(physicalPath);
}
// Return an empty string to signify success
return Content("");
}
i need an answer to this as well....?