zoukankan      html  css  js  c++  java
  • Asp.Net图片上传

    <div>

                            <asp:FileUpload ID="FileUpload1" runat="server" Height="25px"/>
                            <asp:ImageButton runat="server" ID="btn_Upload" ImageUrl="~/Activity/images/upload.gif"
                                Style="margin-bottom: -8px;" OnClick="btn_Upload_Click" /><br />
                            <asp:Image ID="imgUrl" runat="server" Visible="false" /></div> 

    protected void btn_Upload_Click(object sender, ImageClickEventArgs e)
            {
                string path = "/uploadfiles/Activity/";
                string folderPathforsave = Server.MapPath(path);
                if (!Directory.Exists(folderPathforsave))
                {
                    Directory.CreateDirectory(folderPathforsave);
                }

                string filename = FileUpload1.FileName;

                if (filename != "")
                {
                    filename = filename.Substring(filename.LastIndexOf("."));
                    if (filename.ToLower() == ".jpg" || filename.ToLower() == ".bmp" || filename.ToLower() == ".gif")
                    {
                        string strpic = string.Format("{0:yyyyMMddHHmmssffff}", DateTime.Now)+filename;
                        fup_Act_Image.SaveAs(folderPathforsave + strpic);
                        path += strpic;
                        imgUrl.Visible = true;
                        imgUrl.ImageUrl = path;
                    }
                    else
                    {
                        MsgBox.MsgBoxShow(this.Page, "支持jpg,bmp,gif等上传文件格式!");
                        return;
                    }
                }
            }

  • 相关阅读:
    android 布局边框的使用,在xml文件中配置边框大小及颜色
    android去掉layout顶部的阴影(状态栏下边的阴影)
    ExpandableListView
    addTextChangedListener有错
    Android EditText____TextchangedListener
    LinkedHashMap.get("key")
    适配器模式(Java代码)
    单例模式(Java代码)
    工厂方法模式(Java代码)
    质数算法
  • 原文地址:https://www.cnblogs.com/Bright/p/2232023.html
Copyright © 2011-2022 走看看