how do I remove the upload done and change it to "ok"
@(Html.Kendo().Upload().Name("files")
.TemplateId("fileTemplate")
.Multiple(false)
.Messages(m => m.Select("Selecionar Arquivo...").UploadSelectedFiles("Importar").StatusUploading("OK").StatusUploaded("OK"))
.Async(a => a
.Save("SaveAsync", "Util")
.Remove("Remove", "Util")
.AutoUpload(false))
.HtmlAttributes(new { accept = ".xml,.xlsx,.xlsb,.xls" })
.Events(e => e.Error("uploadError").Complete("carregarGridErros")))
Several of the examples use a getFileInfo(e) routine to pull out the file list in the upload control. This works well in events like onSelect().
Is it possible to retrieve the filename or list of files in the client side onComplete(e) event?
I'm trying to set up an upload for some quite large files, which involves using chunked asynchronous uploads.
Once the file has been transferred, a record is saved to a database, with details of the file name, and an ID passed back to the web page.
I was able to get this working when the upload wasn't using chunks, but I'm now a bit stuck.
The example in your documentation (https://docs.telerik.com/aspnet-mvc/html-helpers/editors/upload/chunk-upload ) seems to be written for .later versions of the >NET framework (or .NET core), as I cannot find namespaces to include IFormFile or JsonSerializer . I'm using .NET Framework 4.7.2
I have got a version working (the file is saved to the upload folder), however, when the upload is complete, it does not call the Save procedure., which saves a record to a database, renames the file, and passes back a fileID.
The code is:-
public
ActionResult ChunkSave(IEnumerable<HttpPostedFileBase> files,
string
metaData)
{
if
(metaData ==
null
)
{
return
Save(files);
}
MemoryStream ms =
new
MemoryStream(Encoding.UTF8.GetBytes(metaData));
var serializer =
new
DataContractJsonSerializer(
typeof
(ChunkMetaData));
ChunkMetaData chunkData = serializer.ReadObject(ms)
as
ChunkMetaData;
string
path = String.Empty;
string
uploadFolder = SystemsPortal.Properties.Settings.Default.GLInterfaceUploadFolder;
if
(chunkData.chunkIndex == 0)
{
//1st chunk - check if file exists, and if so, delete before saving
path = Path.Combine(uploadFolder, chunkData.fileName);
if
(System.IO.File.Exists(path))
{
System.IO.File.Delete(path);
}
}
path = String.Empty;
// The Name of the Upload component is "files"
if
(files !=
null
)
{
foreach
(var file
in
files)
{
path = Path.Combine(uploadFolder, chunkData.fileName);
AppendToFile(path, file.InputStream);
}
}
Models.FileResult fileBlob =
new
Models.FileResult();
fileBlob.uploaded = chunkData.totalChunks - 1 <= chunkData.chunkIndex;
fileBlob.fileUid = chunkData.uploadUid;
return
Json(fileBlob);
}
The control definition is:-
@(Html.Kendo().Upload()
.Name(
"files"
)
.Multiple(
false
)
.Events(e => e.Success(
"ulSuccess"
))
.Async(a => a
.Save(
"ChunkSave"
,
"GLInterfaceUpload"
)
.ChunkSize(250000)
.AutoUpload(
true
)
)
)
function ulSuccess(e) {
var response = e.XMLHttpRequest.responseText;
fileID = response;
alert(fileID);
e.sender.enable(false);
$('#divButton').show();
}
The Success event does fire, but the data returned, but as the Save procedure has never been called, no fileID is passed back.
How can I get this working as it should?
Thanks
@(Html.Kendo().Upload()
.Name(
"CreateMediaSelect"
)
.Async(a => a
.Save(
"MyActionName"
,
"ControllerName"
)
.AutoUpload(
true
)
)
.Events(events => events
.Success(
"OnSuccess"
)
.Upload(
"OnUpload"
)
)
)
public ActionResult MyActionName(IEnumerable<
HttpPostedFileBase
> CreateMediaSelect)
@using (Ajax.BeginForm("Save", "Manage", null, new AjaxOptions {HttpMethod = "POST"}, new { enctype = "multipart/form-data", @id = "form", target = "_self" }))
@using (Html.BeginForm("Save", "Manage", FormMethod.Post, new { enctype = "multipart/form-data" }))
[HttpPost]
public ActionResult Save (Model model, IEnumerable<
HttpPostedFileBase
> file)
@(Html.Kendo().Upload()
.Name("files")
.Async(a => a
.Save("Chunk_Upload_Save", "Home")
.Remove("Async_Remove", "Home")
.AutoUpload(true)
.ChunkSize(1024000) //bytes
)
.Events(events => events
.Cancel("onCancel")
)
)
Hi,
I want to display the existing files based on the value of the HttpPostedFileBase properties in my view model. How can I achieve this without using asynchronous uploading?
I tried what is written in this blog but whenever I save the form, the value of the files are lost.
Form:
@(Html.Kendo().Upload()
.Name("LogoImage")
.Multiple(false)
.Messages(m => m.Select("Upload"))
.Validation(validation => validation
.AllowedExtensions(new string[] { ".gif", ".jpg", ".png" })
.MaxFileSize(2097152)
)
)
View model:
public HttpPostedFileBase LogoImage { get; set; }
Hi Telerik Family,
I have kendo upload and i'm uploading some image and video with that . I need to check image width and height of image so than i can understand image is proper or not proper.
I checked you have "e.files[0].size" value for .Select() event but that is not useful for me.
What you suggest?
Thanks