我想通过 pdf 或 text 等剑道文件上传。我在将文件名或路径发送到我的控制器时遇到了一些问题
这是我的看法
<div class="editor-field" id="files">
@(Html.Kendo().Upload()
.Name("Documents")
.Async(async => async
.Save("UploadDocument", "Controller"))
.Multiple(false)
.ToClientTemplate())
</div>
这是我的 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 });
}
我需要一个模型来传递值或 JS 函数吗?