I want to upload through kendo files like pdf or text. Ihave some issues with sending the filename or path to my controller
Here is my view
<div class="editor-field" id="files">
@(Html.Kendo().Upload()
.Name("Documents")
.Async(async => async
.Save("UploadDocument", "Controller"))
.Multiple(false)
.ToClientTemplate())
</div>
And here is my ActionController
public ActionResult UploadDocument()
{
var doc = Request.Files["document"];
var inputstream = doc.InputStream;
var filename = doc.FileName;
var doctype=doc.ContentType;
var storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["AzureStorageConnection"].ConnectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("document");
container.CreateIfNotExists();
var permission = container.GetPermissions();
string uniqueBlobName= string.Format("documents/{0}", filename);
CloudBlockBlob blob = container.GetBlockBlobReference(uniqueBlobName);
blob.Properties.ContentType = doctype;
blob.UploadFromStream(inputstream);
return Json(new { success = true });
}
Do I need a model for passing the values or JS function?
@(Html.Kendo().Upload().Name("Documents")
According to the code of your view, you set the name of the upload control to 'Documents'. To get the information of the uploaded file, you also need to use this name 'Documents' instead of 'document' in your controller. Please change your code as following.
var doc = Request.Files["Documents"];
var filename = doc.FileName;
I just tested Kendo Upload control using upper code on my side, I can get the path of the uploaded file.