±êÌ⣺ΪʲôִֻÐÐelseÓï¾ä£¿
È¡ÏûÖ»¿´Â¥Ö÷
Teem
Rank: 2
À´¡¡×Ô£º¹ã¶«
µÈ¡¡¼¶£ºÂÛ̳ÓÎÃñ
Ìû¡¡×Ó£º54
ר¼Ò·Ö£º36
×¢¡¡²á£º2012-12-24
½áÌûÂÊ£º87.5%
ÒѽáÌù¡Ì  ÎÊÌâµãÊý£º5 »Ø¸´´ÎÊý£º3 
ΪʲôִֻÐÐelseÓï¾ä£¿
³ÌÐò´úÂ룺
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class FileUpload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        bool filesValib = false;
        if (this.FileUpload1.HasFile)
        {
            string fileExtension = (this.FileUpload1.FileName).ToLower();
            string[] restricExtension = { "gif", "jpg", "bmp", "png" };
            for (int i = 0; i < restricExtension.Length; i++)
            {
                if (fileExtension == restricExtension[i])
                {
                    filesValib = true;
                }
            }

            if (filesValib == true)
            {
                try
                {
                    this.Image1.ImageUrl = "../../WebSite7/Image/password.gif";
                    this.FileUpload1.SaveAs(Server.MapPath("~/images/") + FileUpload1.FileName);
                    this.Label1.Text = "ÎļþÉÏ´«³É¹¦";
                    this.Label1.Text += "<br/>";
                    this.Label1.Text += "<li>" + "Ô´Îļþ·¾¶£º" + this.FileUpload1.PostedFile.FileName;
                    this.Label1.Text += "<br/>";
                    this.Label1.Text += "<li>" + "Îļþ´óС£º" + this.FileUpload1.PostedFile.ContentLength + "×Ö½Ú";
                    this.Label1.Text += "<br/>";
                    this.Label1.Text += "<li>" + "ÎļþÀàÐÍ:" + this.FileUpload1.PostedFile.ContentType;
                }

                catch
                {
                    this.Label1.Text = "ÎļþÉÏ´«²»³É¹¦£¡";
                }

                finally
                {

                }
            }
            else

            {
                this.Label1.Text = "Ö»Äܹ»ÉÏ´«ºó׺ÃûΪjpg, gif, png, bmpµÄÎļþ";
            }
        }
    }
}

Ñ¡ÖÐͼƬ¸ñʽµÄµÄÎļþµã»÷ÉÏ´«  »¹ÊÇÖ±½ÓÌøµ½elseÓï¾ä  Çó½âÊÍ
2013-07-30 17:52
Teem
Rank: 2
À´¡¡×Ô£º¹ã¶«
µÈ¡¡¼¶£ºÂÛ̳ÓÎÃñ
Ìû¡¡×Ó£º54
ר¼Ò·Ö£º36
×¢¡¡²á£º2012-12-24
µÃ·Ö:0 
¸Ðл

                                  ~~~~ ÌìµÀ³êÇÚ
2013-07-31 09:15
Teem
Rank: 2
À´¡¡×Ô£º¹ã¶«
µÈ¡¡¼¶£ºÂÛ̳ÓÎÃñ
Ìû¡¡×Ó£º54
ר¼Ò·Ö£º36
×¢¡¡²á£º2012-12-24
µÃ·Ö:0 
³ÌÐò´úÂ룺
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class FileUpload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        bool filesValib = false;
        if (this.FileUpload1.HasFile)
        {
            string fileExtension = (this.FileUpload1.FileName).ToLower();
            string[] restricExtension = { ".gif", ".jpg", ".bmp", ".png" };
            for (int i = 0; i < restricExtension.Length; i++)
            {
                if (fileExtension == restricExtension[i])
                {
                    filesValib = true;
                }
            }

            if (filesValib == true)
            {
                try
                {
                    this.Image1.ImageUrl = "~/images/"+FileUpload1.FileName;
                    this.FileUpload1.SaveAs(Server.MapPath("~/images/") + FileUpload1.FileName);
                    this.Label1.Text = "ÎļþÉÏ´«³É¹¦";
                    this.Label1.Text += "<br/>";
                    this.Label1.Text += "<li>" + "Ô´Îļþ·¾¶£º" + this.FileUpload1.PostedFile.FileName;
                    this.Label1.Text += "<br/>";
                    this.Label1.Text += "<li>" + "Îļþ´óС£º" + this.FileUpload1.PostedFile.ContentLength + "×Ö½Ú";
                    this.Label1.Text += "<br/>";
                    this.Label1.Text += "<li>" + "ÎļþÀàÐÍ:" + this.FileUpload1.PostedFile.ContentType;
                }

                catch
                {
                    this.Label1.Text = "ÎļþÉÏ´«²»³É¹¦£¡";
                }

                finally
                {

                }
            }
            else

            {
                this.Label1.Text = "Ö»Äܹ»ÉÏ´«ºó׺ÃûΪjpg, gif, png, bmpµÄÎļþ";
            }
        }
    }
}


ÏÖÔÚ°Ñ´úÂë¸ÄºÃÁË£¬µ«ÊÇ×ÜÊÇÉÏ´«²»³É¹¦£¬ÓÖ²»ÖªµÀÄÄÀï´íÁË£¿  Çó½Ì~~~~~~~~

                                  ~~~~ ÌìµÀ³êÇÚ
2013-07-31 09:29
Teem
Rank: 2
À´¡¡×Ô£º¹ã¶«
µÈ¡¡¼¶£ºÂÛ̳ÓÎÃñ
Ìû¡¡×Ó£º54
ר¼Ò·Ö£º36
×¢¡¡²á£º2012-12-24
µÃ·Ö:0 
»Ø¸´ 5Â¥ shangsharon
ûÓб¨´í£¬ Ñ¡ÖÐͼƬ¸ñʽ  ¿ÉÊÇÉÏ´«²»³É¹¦

                                  ~~~~ ÌìµÀ³êÇÚ
2013-08-01 10:57



²ÎÓëÌÖÂÛÇëÒƲ½Ô­ÍøÕ¾Ìù×Ó£ºhttps://bbs.bccn.net/thread-418277-1-1.html




¹ØÓÚÎÒÃÇ | ¹ã¸æºÏ×÷ | ±à³ÌÖйú | Çå³ýCookies | TOP | ÊÖ»ú°æ

±à³ÌÖйú °æȨËùÓУ¬²¢±£ÁôËùÓÐȨÀû¡£
Powered by Discuz, Processed in 0.250646 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved