I am using Kendo Upload but without the MVC wrappers. I am unable to get the files at the controller to save.
What am I doing wrong. I've tried this multiple ways and nothing seems to get the file.
[HttpPost]
[ValidateAntiForgeryToken]
public
ActionResult Edit([Bind(Include =
"fileID,galleryItemID,width,height"
)] GalleryItemFile galleryFile, IEnumerable<HttpPostedFileBase> uplFile)
{
if
(ModelState.IsValid)
{
GalleryItemFile thisGalleryFile = db.GalleryItemFiles.Find(galleryFile.fileID);
if
(uplFile !=
null
)
{
foreach
(var inputFile
in
uplFile)
{
//HttpPostedFileBase uploadedFile = Request.Files[inputFile];
if
(inputFile !=
null
&& inputFile.ContentLength > 0)
{
string
filename = galleryFile.galleryItem.imageName + DateTime.Now.ToString(
"yyyyMMdd-HHmm-ss"
);
filename = filename.Replace(
" "
,
"-"
) +
"."
+ Path.GetExtension(inputFile.FileName);
string
filepath = Path.Combine(Server.MapPath(
"~/Areas/Gallery/Content/GalleryFiles"
), filename);
inputFile.SaveAs(filepath);
galleryFile.filename = filename;
galleryFile.filepath = Path.Combine(
"~/Areas/Gallery/Content/GalleryFiles"
, filename);
}
}
}
@model Marketing.Areas.Gallery.Models.GalleryItemFile
@using (Ajax.BeginForm("Edit", new { id = Model.fileID }, new AjaxOptions { UpdateTargetId = "slideoutmenu", InsertionMode = InsertionMode.Replace, HttpMethod = "Post" }, new { enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
@Html.HiddenFor(model => model.galleryItem.galleryItemID)
@Html.HiddenFor(model => model.fileID)
<
table
class
=
"formtable"
>
<
tr
><
td
colspan
=
"2"
class
=
"tableheader"
>Edit Gallery File Item</
td
></
tr
>
<
tr
>
<
td
>Upload File:</
td
>
<
td
><
input
type
=
"file"
name
=
"uplFile"
id
=
"uplFile"
/></
td
>
</
tr
>
<
tr
>
<
td
>Item Name:</
td
>
<
td
>@Html.EditorFor(model => model.width)</
td
>
</
tr
>
<
tr
>
<
td
>Description:</
td
>
<
td
>@Html.EditorFor(model => model.height)</
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"2"
><
input
type
=
"submit"
value
=
"Save"
class
=
"btn btn-default"
/> <
input
type
=
"submit"
value
=
"Cancel"
class
=
"btn btn-cancel"
onclick
=
"slideOutMenuClose(); $('#slideoutmenu').html('');"
/></
td
>
</
tr
>
</
table
>
<
script
>
$("#uplFile").kendoUpload();
</
script
>
}
What am I doing wrong. I've tried this multiple ways and nothing seems to get the file.