源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

JQuery.uploadify 上传文件插件的使用详解 for ASP.NET

  • 时间:2022-12-17 18:18 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:JQuery.uploadify 上传文件插件的使用详解 for ASP.NET
后来朋友推荐了一个这个叫uploadify的上传插件,似乎挺好,就到官方下了个示例运行,感觉挺好,自己再稍加美化一下就OK 了..! 接下来就讲讲使用过程吧: 1. 下载    官方网站:[url=http://www.uploadify.com/]http://www.uploadify.com/[/url]    直接下载:[url=http://xiazai.1sucai.cn/201001/yuanma/jquery.uploadify.rar]jquery.uploadify-v2.1.0.rar[/url]    我的Demo: [url=http://xiazai.1sucai.cn/201001/yuanma/MyUpload.rar]MyUpload.rar[/url]                官方网站也有demo    下载解压后:       [img]http://img.1sucai.cn/uploads/article/2018010710/20180107100115_0_5165.png[/img]      说明:它里面有demo  但是是PHP的,还有一个帮助文档:uploadify v2.1.0 Manual.pdf. 2.创建工程:     结构如图>>     [img]http://img.1sucai.cn/uploads/article/2018010710/20180107100116_1_35484.png[/img]     文件说明:      A.js文件夹下的所有文件:必需,从下载下来的包里解压复制过来,名字可以自己改改    B.Default.aspx:测试页,后台没有代码
[url=js/uploadify.css]<script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/swfobject.js"></script> <script type="text/javascript" src="js/jquery.uploadify.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#uploadify").uploadify({ 'uploader': 'js/uploadify.swf', 'script': 'Upload.aspx', 'cancelImg': 'js/cancel.png', 'folder': 'upload', 'queueID': 'fileQueue', 'auto': false, 'multi': true, }); }); </script> </head> <body> <form id="form1" runat="server"> <input type="file" name="uploadify" id="uploadify" /> <a href="javascript:$('#uploadify').uploadifyUpload()">上传</a>| <a href="javascript:$('#uploadify').uploadifyClearQueue()"> 取消上传</a> <div id="fileQueue"></div> </form> </body> </html>
C.Upload.aspx: 处理上传文件 代码
[u]复制代码[/u] 代码如下:
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.IO; namespace WebApplication2 { public partial class Upload : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { HttpPostedFile file = Request.Files["FileData"]; string uploadpath = Server.MapPath(Request["folder"] + "\"); if (file != null) { if (!Directory.Exists(uploadpath)) { Directory.CreateDirectory(uploadpath); } file.SaveAs(uploadpath + file.FileName); Response.Write("1"); } else { Response.Write("0"); } } } }
D.upload这个文件加也是必需 3.运行结果:    [img]http://img.1sucai.cn/uploads/article/2018010710/20180107100116_2_56171.png[/img] 4.最后说说:这个只是一个简单的入门例子,至于界面可以根据自己的需要去改
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部