码迷,mamicode.com
首页 > Web开发 > 详细

基于jquery.uploadify的asp.net大文件上传

时间:2015-05-29 20:06:59      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:

     以前项目的上传都是十几兆的文件,虽然没有进度条,但客户端响应比较快,客户还能接受。在新项目中,客户提供的Excel,要求导入到系统中,但Excel偶尔会将近百兆,客户对上传的使用体验提出了要求。后来在园子里找了朋友写的博客,加上自己的整理,最终实现了基于asp.net的带进度条的百兆文件上传。

在这里首先感谢两位园友,在这里附上参考的两位园友的博客。

    马维拉的真实之眼http://www.cnblogs.com/telephoner/p/3185081.html

    oec2003http://www.cnblogs.com/oec2003/archive/2010/01/06/1640027.html

下面是我在两位朋友的基础上做的完善。

  1. webconfig的配置完善
    <?xml version="1.0"?>
    <configuration>
      <appSettings/>
      <connectionStrings/>
      <system.web>
        <httpRuntime executionTimeout="200000"
                 maxRequestLength="409600"
                 requestLengthDiskThreshold="80"
                 useFullyQualifiedRedirectUrl="false"
                 minFreeThreads="8"
                 minLocalRequestFreeThreads="4"
                 appRequestQueueLimit="5000"
                 enableKernelOutputCache="true"
                 enableVersionHeader="true"
                 requireRootedSaveAsPath="true"
                 enable="true"
                 shutdownTimeout="90"
                 delayNotificationTimeout="5"
                 waitChangeNotification="0"
                 maxWaitChangeNotification="0"
                 enableHeaderChecking="true"
                 sendCacheControlHeader="true"
                 apartmentThreading="false" />
    
     
        <compilation debug="true" targetFramework="4.0">
        </compilation>
        
        <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
      </system.web>
      <!-- 
            在 Internet 信息服务 7.0 下运行 ASP.NET AJAX 需要 system.webServer
            节。对早期版本的 IIS 来说则不需要此节。
        -->
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules runAllManagedModulesForAllRequests="true" />
        <security>
          <requestFiltering>
            <requestLimits maxAllowedContentLength="2147483647"></requestLimits>
          </requestFiltering>
        </security>
      </system.webServer>
    </configuration>

     

  2. 修改 $("#uploadify").uploadify实现动态传参
                $("#uploadify").uploadify({
                    uploader: jquery.uploadify-v2.1.0/uploadify.swf,
                    script: UploadHandler.ashx,
                    cancelImg: jquery.uploadify-v2.1.0/cancel.png,
                    folder: UploadFile,
                    queueID: fileQueue,
                    auto: false,                             //设置为true当选择文件后就直接上传了,为false需要点击上传按钮才上传        
                    multi: false,                           //设置为true时可以上传多个文件
                    fileDesc: 请选择Excel(xls|xlsx)文件, //这个属性值必须设置fileExt属性后才有效,用来设置选择文件对话框中的提示文本
                    fileExt: *.xls;*.xlsx, //设置可以选择的文件的类型
                    //‘buttonText‘: ‘请选择‘, //浏览按钮文本,默认值:BROWSE 
                    hideButton: false, //是否隐藏浏览按钮
                    scriptData: { jzyd: $(#DropDownListYear).val() + $(#DropDownMonth).val(), tablename: $(#Hidden1).text() }, //这里只能传静态参数  
                    onSelect: function (event, queueID, fileObj) {
                        $("#uploadify").uploadifySettings("scriptData", { jzyd: $(#DropDownListYear).val() + $(#DropDownMonth).val(), tablename: $(#Hidden1).text() });
                    }  //动态更新配(执行此处时可获得值)
                });

     

 

基于jquery.uploadify的asp.net大文件上传

标签:

原文地址:http://www.cnblogs.com/XieDong/p/4539213.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!