【问题标题】:Kendo UI Upload widget - saveField and saveUrlKendo UI 上传小部件 - saveField 和 saveUrl
【发布时间】:2023-04-03 23:42:01
【问题描述】:

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

//// 服务声明 公共接口 ISampleWcf { [运营合同] [WebGet(BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] 无效 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>

【问题讨论】:

  • 请有任何建议

标签: html kendo-ui asyncfileupload


【解决方案1】:

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

public void SaveAttachments(List<HttpPostedFileBase> customSaveField)

【讨论】:

    猜你喜欢
    • 2013-01-03
    • 1970-01-01
    • 1970-01-01
    • 2021-12-05
    • 2014-10-15
    • 1970-01-01
    • 1970-01-01
    • 2014-11-19
    • 1970-01-01
    相关资源
    最近更新 更多