Hello,
I have this issue, I am trying to upload files via kendo upload and if the file format is .txt it is uploading the file properly. When I tried the same with .pdf, it always fails. I even tried all other file types like .doc, .xls, .csv etc. but they keep failing. I don't know what I am doing wrong. The following is my implementation of kendo Upload.
HTML: <input id="files" type="file" name="files" />
JQUERY: $("#files").kendoUpload(
{
multiple:true,
//upload: onUpload,
async: {
saveUrl: "/Bank/Save",
//removeUrl: "/Bank/Remove",
autoUpload: true,
}
});
C#: public ActionResult Save(IEnumerable<HttpPostedFileBase> files)
{
//The Name of the Upload component is "files"
if (files != null)
{
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(@"C:\New Folder\", fileName); //Server.MapPath("~/App_Data")
// The files are not actually saved in this demo
file.SaveAs(physicalPath);
}
}
// Return an empty string to signify success
return Content("");
}
public ActionResult Remove(string[] files)
{
// The parameter of the Remove action must be called "fileNames"
if (files != null)
{
foreach (var fullName in files)
{
var fileName = Path.GetFileName(fullName);
var physicalPath = Path.Combine(@"C:\New Folder\", fileName);
// TODO: Verify user permissions
if (System.IO.File.Exists(physicalPath))
{
// The files are not actually removed in this demo
System.IO.File.Delete(physicalPath);
}
}
}
// Return an empty string to signify success
return Content("");
}