Grails 使用剑道用户界面上传文件
我必须在grails应用程序中使用KendoUI添加上传文件功能。我还必须知道如何更改上传位置Grails 使用剑道用户界面上传文件,grails,kendo-ui,Grails,Kendo Ui,我必须在grails应用程序中使用KendoUI添加上传文件功能。我还必须知道如何更改上传位置 thnks在此处查看KendoUI上传配置文档: async对象上的saveUrl选项允许您轻松设置提交文件的处理程序。请在此处查看KendoUI上载配置文档: async对象上的saveUrl选项允许您轻松地为提交的文件设置处理程序。下面是我们提出的在Kendo UI Upload小部件上动态更改saveUrl的解决方案 控制器代码: public class MediaController : A
thnks在此处查看KendoUI上传配置文档:
async对象上的saveUrl选项允许您轻松设置提交文件的处理程序。请在此处查看KendoUI上载配置文档:
async对象上的saveUrl选项允许您轻松地为提交的文件设置处理程序。下面是我们提出的在Kendo UI Upload小部件上动态更改saveUrl的解决方案 控制器代码:
public class MediaController : ApiControllerBase
{
public Task<HttpResponseMessage> Post()
{
var queryVals = Request.RequestUri.ParseQueryString();
string idValue = queryVals["id"].ToString();
... CODE REMOVE FOR BREVITY
}
}
和脚本代码:
<div style="width:45%">
<input class="upload" name="files" id="files" type="file" upload-id="02ebeebf-98aa-459b-b41f-49028fa37e9c" />
<input class="upload" name="files2" id="file1" type="file" upload-id="499499D3-1C80-4930-8C8D-C87F17884D3F" />
</div>
<script>
$(document).ready(function () {
$(".upload").kendoUpload({
async: {
saveUrl: "/API/Media",
autoUpload: true
},
upload: function onUpload(e) {
var uploadId = e.sender.wrapper.prevObject.attr("upload-id");
e.sender.options.async.saveUrl = "/api/media?id=" + uploadId;
},
});
});
</script>
下面是我们提出的在KendoUIUpload小部件上动态更改saveUrl的解决方案 控制器代码:
public class MediaController : ApiControllerBase
{
public Task<HttpResponseMessage> Post()
{
var queryVals = Request.RequestUri.ParseQueryString();
string idValue = queryVals["id"].ToString();
... CODE REMOVE FOR BREVITY
}
}
和脚本代码:
<div style="width:45%">
<input class="upload" name="files" id="files" type="file" upload-id="02ebeebf-98aa-459b-b41f-49028fa37e9c" />
<input class="upload" name="files2" id="file1" type="file" upload-id="499499D3-1C80-4930-8C8D-C87F17884D3F" />
</div>
<script>
$(document).ready(function () {
$(".upload").kendoUpload({
async: {
saveUrl: "/API/Media",
autoUpload: true
},
upload: function onUpload(e) {
var uploadId = e.sender.wrapper.prevObject.attr("upload-id");
e.sender.options.async.saveUrl = "/api/media?id=" + uploadId;
},
});
});
</script>
您只需更改saveUrl属性即可。代码应该如下所示:
this.documentUpload.options.async.saveUrl = '/newUrlStr';
您只需更改saveUrl属性即可。代码应该如下所示:
this.documentUpload.options.async.saveUrl = '/newUrlStr';
这行代码保存了我的一天:e.sender.options.async.saveUrl=/api/media?id=+uploadId;谢谢。这行代码帮我节省了时间:e.sender.options.async.saveUrl=/api/media?id=+uploadId;非常感谢。