下载 现在有两个版本了,我此次使用的依然是Flash版本的,虽然现在绝大部分浏览器都兼容HTMKL5,目前位置,除了做手机项目外,一般我们项目中不允许使用HTML5标签。
属性介绍(Options)
auto:是否自动上传,默认值true。如果设置为false,上传文件将会被放入到一个队列中,需要调用upload方法才会将队列中的文件上传到服务器,具体参见upload方法介绍。
1 $(function () { 2 $("#upload").uploadify({ 3 auto: false, 4 swf: '/uploadify/uploadify.swf', 5 uploader: '/ashx/upload.ashx' 6 }); 7 });
效果图:
注意:不调用upload方法,将会永久在队列中。不会自动提交到服务器。
buttonClass:按钮的样式,默认值(Empty String)。想要设置样式还是很麻烦的,首先你要覆盖掉原有的样式,原有样式在uploadify.css(你也可以对次css文件进行精简),这个属性一般不怎么用,项目中让美工切button图片,直接赋值给buttonImage。这里只给出一个使用的例子:
1 .some{ 2 background-color:Red; 3 background-image:none; 4 }
1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Demo.aspx.cs" Inherits="JQ_uploadify.Demo" %> 2 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 4 <html xmlns="http://www.w3.org/1999/xhtml"> 5 <head runat="server"> 6 <title></title> 7 <link href="/uploadify/uploadify.css" rel="stylesheet" type="text/css" /> 8 <link href="/css/css.css" rel="stylesheet" type="text/css" /> 9 <script src="/js/jquery-1.8.3.js" type="text/javascript"></script> 10 <script src="/uploadify/jquery.uploadify.js" type="text/javascript"></script> 11 <script type="text/javascript"> 12 $(function () { 13 $("#upload").uploadify({ 14 'buttonText': '神马', 15 'buttonClass': 'some', 16 'buttonImage': null, 17 'swf': '/uploadify/uploadify.swf', 18 'uploader': '/ashx/upload.ashx' 19 }); 20 }); 21 </script> 22 </head> 23 <body> 24 <form id="form1" runat="server"> 25 <div> 26 <input type="file" name="upload" value="上传" id="upload" /> 27 </div> 28 </form> 29 </body> 30 </html>