• FileUpload上传多张照片


     <asp:FileUpload ID="uploaderInput" runat="server"  multiple="multiple" accept="image/*"/>
                <asp:Button ID="but_imgup" runat="server" Text="照片上传" />
                <asp:Image ID="img_face" runat="server" Width="30" Height="30" />
    #region  上传方法
        public bool Upload()
        {
            HttpFileCollection upFiles = Request.Files;
            if (upFiles.Count > 0)
            {
                string wenjianjia = "a_" + DateTime.Now.ToString("yyyy-MM-dd");
                string savePath = "~/img/" + wenjianjia;
                string savePaths = MapPath(savePath);
                if (!Directory.Exists(savePaths))
                {
                    Directory.CreateDirectory(savePaths);
                }
                for (int i = 0; i < upFiles.Count; i++)
                {
                    string url_a = "a" + DateTime.Now.Ticks.ToString() + i;
                    string url_f = "f" + DateTime.Now.Ticks.ToString() + i;
    
                    string extendName = string.Empty;
                    HttpPostedFile PostedFile = upFiles[i];
                    if (PostedFile.ContentLength > 0)
                    {
                        extendName = Path.GetExtension(PostedFile.FileName.ToLower()).Replace(".", "");
                        //保存 原始图
                        url_a = "/" + url_a + "." + extendName;
                        url_f = "/" + url_f + "." + extendName;
                        string url_as = savePaths + url_a;
                        string url_fs = savePaths + url_f;
                        //苹果手机 图片角度 调整
                        string url = savePaths + url_f;
                        PostedFile.SaveAs(url);
                        RemoveRotateFlips(url, url_as);
                        File.Delete(url);
                        //缩略图
                        MakeThumbnail(url_as, url_fs, 350, 350, "H");
                        File.Delete(url_as);
                        //显示 图片
                        img_face.ImageUrl = savePath + url_f;
                    }
                }
                return true;
            }
            else
            {
                return false;
            }
        }
        #endregion
  • 相关阅读:
    网页布局 选择符 选择符权重
    css基础
    新手入门html 表格 表单 超链接 图片
    新手入门html
    批量安装Windows系统
    无人值守批量安装服务器
    PXE实现无人值守批量安装服务器
    小白必看:零基础安装Linux系统(超级详细)
    项目实战:rsync+sersync实现数据实时同步
    rsync学习笔记
  • 原文地址:https://www.cnblogs.com/nbsp12138/p/11803721.html
Copyright © 2020-2023  润新知