zoukankan      html  css  js  c++  java
  • 关于上传(上传所用到的upload和upload的应用)

    upload.cs

    public class UpLoad
    {
        public UpLoad()
        {
            //
            //TODO: 在此处添加构造函数逻辑
            //
        }
        public static string Up(FileUpload file2)
        {
            string err = "";
            string fullname = file2.PostedFile.FileName;
            string ty = fullname.Substring(fullname.LastIndexOf(".") + 1).ToLower();
            //if (file2.PostedFile.ContentLength == 0)
            //{
            //    err = "上传失败或指定的文件不存在";
            //}
            if (file2.PostedFile.ContentLength / 1024 > 1024)
            {
                err = "图片大于1M,重新传图片";
            }
            if (ty == "gif" || ty == "pjpeg" || ty == "jpg" || ty == "png" )
            {
                err = "";
            }
            else
            {
                err = "格式不对,限制上传(只允许gif/jpg/png格式文件)";
            }
            return err;
        }

        public static string UpVideo(FileUpload file2)
        {
            string err = "";
            string fullname = file2.PostedFile.FileName;
            string ty = fullname.Substring(fullname.LastIndexOf(".") + 1).ToLower();
            //if (file2.PostedFile.ContentLength == 0)
            //{
            //    err = "上传失败或指定的文件不存在";
            //}
            if (file2.PostedFile.ContentLength / 1024 > 10240)
            {
                err = "视频大于10M,重新传视频";
            }
            if (ty == "wmv" || ty == "mp3" || ty == "wma" || ty == "avi" || ty == "asf" || ty == "mpg"||ty=="swf")
            {
                err = "";
            }
            else
            {
                err = "格式不对,限制上传(只允许wma/mp3/wma/avi/asf/mpg格式文件)";

            }
            return err;
        }
        //进行上传表格和软件

        public static string UpJtnw(FileUpload file2)
        {
            string err = "";
            string fullname = file2.PostedFile.FileName;
            string ty = fullname.Substring(fullname.LastIndexOf(".") + 1).ToLower();
            //if (file2.PostedFile.ContentLength == 0)
            //{
            //    err = "上传失败或指定的文件不存在";
            //}
            if (file2.PostedFile.ContentLength / 1024 > 512000)
            {
                err = "软件大于500M,重新传软件";
            }
            if (ty == "rar" || ty == "zip" || ty == "arj" || ty == "jz" || ty == "z" || ty == "exe")
            {
                err = "";
            }
            else
            {
                err = "格式不对,限制上传(只允许rar/zip/arj/jz/z/exe格式文件)";

            }
            return err;
        }

        public static string UpDoc(FileUpload file2)
        {
            string err = "";
            string fullname = file2.PostedFile.FileName;
            string ty = fullname.Substring(fullname.LastIndexOf(".") + 1).ToLower();
            //if (file2.PostedFile.ContentLength == 0)
            //{
            //    err = "上传失败或指定的文件不存在";
            //}
            if (file2.PostedFile.ContentLength / 1024 > 10240)
            {
                err = "文档大于10M,重新传文档";
            }
            //doc、docx、wps、xls、xlsx、et、ppt、dps、pptx和txt
            if (ty == "doc" || ty == "docx" || ty == "xls" || ty == "xlsx" || ty == "ppt" || ty == "pptx"||ty=="txt"||ty=="wps"||ty=="dps"||ty=="et")
            {
                err = "";
            }
            else
            {
                err = "格式不对,限制上传(只允许doc/docx/wps/xls/xlsx/et/ppt/dps/pptx/txt格式文件)";

            }
            return err;
        }
           public static void Photo(string path)
        {
            if (System.IO.Directory.Exists(path) == false)
            {
                System.IO.Directory.CreateDirectory(path);
            }
        }
    }

  • 相关阅读:
    php+mysql折线图
    转载] magento 产品数据表结构
    magento 开启模板路径提示
    magento smtp设置
    magento 搬家
    利用DIV+CSS制作网页过程中常用的基本概念及标签使
    使用CSS创建有图标的网站导航菜单
    在网页中使用H1标记的须注意的事项
    兼容firefox的iframe高度自适应代码
    jQuery: 图片不完全按比例自动缩小
  • 原文地址:https://www.cnblogs.com/licuihua/p/3071205.html
Copyright © 2011-2022 走看看