uploadify ASP.net 使用笔记
Posted joe.fan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了uploadify ASP.net 使用笔记相关的知识,希望对你有一定的参考价值。
<script type="text/javascript" src="jquery.uploadify.min.js"></script
<link rel="Stylesheet" href="uploadify.css" type="text/css" />
<script type="text/javascript"> $(document).ready(function () { $(‘#uploadify‘).uploadify({ ‘swf‘: ‘uploadify.swf‘, ‘buttonText‘: ‘Loading‘, ‘uploader‘: ‘Uploadhandler.ashx‘, ‘queueID‘: ‘fileQueue‘, ‘queueSizeLimit‘: 10, ‘auto‘: false, ‘multi‘: false, ‘removeCompleted‘: true, ‘fileSizeLimit‘: ‘100MB‘, ‘fileTypeDesc‘: ‘Excel文件‘, ‘fileTypeExts‘: ‘*.xls‘, ‘onUploadSuccess‘: function (file, data, response) { layer.closeAll(); layer.open({ type: 1, skin: ‘layui-layer-rim‘, //加上边框 area: [‘520px‘, ‘340px‘], //宽高 content: ‘<div>File Name:‘ + file.name + data + ‘</div>‘ }); }, ‘onUploadError‘: function (event, queueId, fileObj, errorObj) { layer.closeAll(); }, ‘onUploadStart‘: function (file) { $("#uploadify").uploadify("settings", "formData", { ‘ddlregion‘: $(‘#ddlRegionSearch‘).val() }); //动态参数 } }); $(‘#supload‘).click(function supload() { $(‘#uploadify‘).uploadify(‘upload‘, ‘*‘); }); }); </script>
<div> <input type="file" name="uploadify" id="uploadify" /><button id="supload" class="btn">开始上传</button> </div> <div id="fileQueue"></div>
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Charset = "utf-8"; HttpPostedFile file = context.Request.Files["Filedata"]; string uploadPath = context.Request.MapPath("/Upload/Files/"); try { if (file != null) { string fileName = uploadPath + file.FileName; if (!Directory.Exists(uploadPath)) { Directory.CreateDirectory(uploadPath); } //将文件上传至服务器 file.SaveAs(fileName); context.Response.Write("<br>The import is complete!"); } else { context.Response.Write("<br>File loading failure!"); return; } } catch (Exception ex) { context.Response.Write("<br>Exception: " + ex.Message); } }
以上是关于uploadify ASP.net 使用笔记的主要内容,如果未能解决你的问题,请参考以下文章
在 Web 服务器上的 ASp.Net 中使用 uploadify 上传文件时出现 HTTP 405 错误
ASP.NET MVC 复制MVC项目代码到同一个项目的时候报错The request for ‘home’ has found the following matching controll(代码片