html - Kendo UI 上传小部件 - saveField 和 saveUrl

标签 html kendo-ui asyncfileupload

使用Kendo UI upload widget,如何在wcf服务操作中获取上传的文件。使用我的 wcf 方法提供了 saveUrl 选项,但不确定如何获取上传文件的详细信息。仍然无法理解 saveField 选项的用途。请建议。

////服务声明 公共(public)接口(interface) ISampleWcf { [操作合约] [WebGet(BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] void DoWork();

        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
        void SaveAttachments(List<HttpPostedFileBase> files);
    }

////服务实现。

public class SampleWcf : ISampleWcf
    {
        public void DoWork()
        {
        }

        public void SaveAttachments(List<HttpPostedFileBase> files)
        {
            //HttpPostedFile file;
            var current = System.Web.HttpContext.Current;
            if(current != null)
            {
                var f = current.Request["files"];
            }
        }
    }

////Jquery脚本

$("#files").kendoUpload({
                     async: {
                         saveUrl: "SampleWcf.svc/SaveAttachments",
                         saveField: "customSaveField",
                         autoUpload: true
                     },
                     success: onSuccess,
                     error: onError
                 });

                 function onSuccess(e) {
                     alert('s');
                 }

                 function onError(e) {
                     // Array with information about the uploaded files
                     var files = e.files;

                     if (e.operation == "upload") {
                         alert("Failed to upload " + files.length + " files");
                     }
                 }

/////Web.Config 文件

<?xml version="1.0"?>


<configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
    </system.web>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="serviceBehavior" name="WebApplication1.SampleWcf">
        <endpoint address="" contract="WebApplication1.ISampleWcf" behaviorConfiguration="webSupport"
                  binding="webHttpBinding"  bindingConfiguration="webServiceBinding" name="jsonEndPoint">
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="webSupport">
          <webHttp />
        </behavior>

      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="serviceBehavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <webHttpBinding>
        <binding name="webServiceBinding" maxBufferSize="2147483647"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="34" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>


      </webHttpBinding>
    </bindings>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"></serviceHostingEnvironment>
  </system.serviceModel>

</configuration>

最佳答案

“Async saveField”的值为“customSaveField”。然后它应该与您的 SaveAttachments 的参数名称相匹配。

public void SaveAttachments(List<HttpPostedFileBase> customSaveField)

关于html - Kendo UI 上传小部件 - saveField 和 saveUrl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26042104/

相关文章:

jquery - 从 Kendo 下拉列表中返回值

jquery - 具有 Kendo UI 网格的列中的部分 View

javascript - 如何检查用户是否中断了ajax上传

asp.net - 通过按钮触发 AsyncFileUpload 控件

javascript - 无法动态向数组添加元素

html - 手机上的导航图像

css - 当内容不同时,一行设置大小的 div 不对齐

html - 两个图像和两个文本行对齐

javascript - 使用 Javascript 更改 Kendo TreeView 节点名称 - 我不知道如何执行此操作

c# - 在 asp.net 中更新 UpdatePanel 中的图像 url