zoukankan      html  css  js  c++  java
  • uploadify+C#实例

    首先去uploadify官网下载最新的uploadify    flash文件包, html5是需要收费的

    下载后 官网提供了相应的app供参考的

    我下载的文件如下:

    放到我们系统的时候 有几个地方要改下:

    1:首先是uploadify.css

    由于他取消的按钮样式的背景默认是../img/...

    所以我们要改成 可以根据你的需求改

    .uploadify-queue-item .cancel a {
     background: url('/uploadify/uploadify-cancel.png') 0 0 no-repeat;
    .....
    }

    2:在页面一般引用的是压缩js

    我用的是jquery.uploadify.min.js

    但是里面有一些提示是英文,那么找到里面的一些提示信息,改成相应的中文就行 我的已经改了

    下载地址在最下面的

    3:然后是页面的代码如下


    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <link href="uploadify/uploadify.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form id="form1" runat="server">
        <input id="file_upload_1" type="file" />
        <input id="ibtnSumbit" type="button" value="提交" />
        </form>
    </body>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#file_upload_1").uploadify({
                uploader: '/UploadHandler.ashx',//上传文件后保存文件 后台代码地址
                swf: '/uploadify/uploadify.swf',//功能flash地址
                90,//长度
                height: 20,//高度
                queueSizeLimit: 6,//限定上传文件个数
                checkExisting: '/uploadify/check-exists.php',//检定文件是否存在后台代码地址
                buttonText: '点击上传文件',
                fileSizeLimit: '1000KB', //上传文件的大小限制,单位为字节 100k
                auto: false, //当文件被添加到队列时,自动上传  
                multi: true, //设置为true将允许多文件上传  
                fileTypeExts: '*.gif; *.jpg; *.png', //允许上传的文件后缀  
                fileDesc: '只能选择格式 (.JPG, .GIF, .PNG)', //在浏览窗口底部的文件类型下拉菜单中显示的文本  
                onQueueComplete: function () {
                    alert('上传成功');
                    //上传成功后不允许在上传即上传按钮失效(按实际要求)
                    $("#file_upload_1").uploadify('disable', true);
                    //提交按钮失效
                    $("#ibtnSumbit").unbind("click");
                }
            });
            $("#ibtnSumbit").bind("click", function () {
                //动态调用上传事件
                $("#file_upload_1").uploadify("upload", "*");
            });
        });
    </script>
    </html>

    UploadHandler.ashx 代码如下

    <%@ WebHandler Language="C#" Class="UpLoader" CodeBehind="~/App_Code/UpLoader.cs"  %>

    ~/App_Code/UpLoader.cs代码如下

    using System;
    using System.Web;

    /// <summary>
    ///UpLoader 的摘要说明
    /// </summary>
    public class UpLoader: IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset = "utf-8";

            HttpPostedFile file = context.Request.Files["Filedata"];
            string uploadPath = HttpContext.Current.Server.MapPath(@"/images/")+System.DateTime.Today.ToShortDateString()+"/";
          
            if (file != null)
            {
                if (!System.IO.Directory.Exists(uploadPath))
                {
                    System.IO.Directory.CreateDirectory(uploadPath);
                }
                file.SaveAs(System.IO.Path.Combine(uploadPath, file.FileName));
                context.Response.Write("1");
            }
            else
            {
                context.Response.Write("0");
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

    }


    好了 这样就可以了 代码我现在传进去  直接运行就行

    http://download.csdn.net/detail/yefighter/5268657


  • 相关阅读:
    如何显示Mac中文件的路径(path)
    什么样的音符对听起来悦耳?
    如何用iMovie剪辑视频
    【转】基因的故事
    4阶魔方解决方案
    SQ1魔方解决方案
    如何将Wikipedia链接的Unicode编码转成百分号编码
    我喜欢的LaTex编辑器
    react(redux)
    React (高阶组件)
  • 原文地址:https://www.cnblogs.com/xinyuyuanm/p/3027128.html
Copyright © 2011-2022 走看看