| ÍøÕ¾Ê×Ò³ | Òµ½çÐÂÎÅ | С×é | Íþ¿Í | È˲Š| ÏÂÔØƵµÀ | ²©¿Í | ´úÂëÌù | ÔÚÏß±à³Ì | ±à³ÌÂÛ̳
»¶Ó­¼ÓÈëÎÒÃÇ£¬Ò»Í¬Çд輼Êõ
Óû§Ãû£º   
 
ÃÜ¡¡Â룺  
¹²ÓÐ 746 È˹Ø×¢¹ý±¾Ìû
±êÌ⣺ΪʲôִֻÐÐelseÓï¾ä£¿
Ö»¿´Â¥Ö÷ ¼ÓÈëÊÕ²Ø
Teem
Rank: 2
À´¡¡×Ô£º¹ã¶«
µÈ¡¡¼¶£ºÂÛ̳ÓÎÃñ
Ìû¡¡×Ó£º54
ר¼Ò·Ö£º36
×¢¡¡²á£º2012-12-24
½áÌûÂÊ£º87.5%
ÊÕ²Ø
ÒѽáÌù¡Ì  ÎÊÌâµãÊý£º5 »Ø¸´´ÎÊý£º7 
ΪʲôִֻÐÐ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
shangsharon
Rank: 9Rank: 9Rank: 9
À´¡¡×Ô£ººþ±±Î人
µÈ¡¡¼¶£ºÖ©ÖëÏÀ
Íþ¡¡Íû£º7
Ìû¡¡×Ó£º221
ר¼Ò·Ö£º1261
×¢¡¡²á£º2012-3-25
ÊÕ²Ø
µÃ·Ö:3 
string[] restricExtension = { "gif", "jpg", "bmp", "png" };
¸ÄΪ
string[] restricExtension = { ".gif", ".jpg", ".bmp", ".png" };
2013-07-30 23:50
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
shangsharon
Rank: 9Rank: 9Rank: 9
À´¡¡×Ô£ººþ±±Î人
µÈ¡¡¼¶£ºÖ©ÖëÏÀ
Íþ¡¡Íû£º7
Ìû¡¡×Ó£º221
ר¼Ò·Ö£º1261
×¢¡¡²á£º2012-3-25
ÊÕ²Ø
µÃ·Ö:0 
ûÓÐÉÏ´«³É¹¦»¹ÊÇûÓб£´æ³É¹¦?ÓÐûÓб¨Ê²Ã´´í?
2013-07-31 22:04
Teem
Rank: 2
À´¡¡×Ô£º¹ã¶«
µÈ¡¡¼¶£ºÂÛ̳ÓÎÃñ
Ìû¡¡×Ó£º54
ר¼Ò·Ö£º36
×¢¡¡²á£º2012-12-24
ÊÕ²Ø
µÃ·Ö:0 
»Ø¸´ 5Â¥ shangsharon
ûÓб¨´í£¬ Ñ¡ÖÐͼƬ¸ñʽ  ¿ÉÊÇÉÏ´«²»³É¹¦

                                  ~~~~ ÌìµÀ³êÇÚ
2013-08-01 10:57
shangsharon
Rank: 9Rank: 9Rank: 9
À´¡¡×Ô£ººþ±±Î人
µÈ¡¡¼¶£ºÖ©ÖëÏÀ
Íþ¡¡Íû£º7
Ìû¡¡×Ó£º221
ר¼Ò·Ö£º1261
×¢¡¡²á£º2012-3-25
ÊÕ²Ø
µÃ·Ö:0 
ÄÜ×ßµ½ÕâÒ»²½Âð?
this.FileUpload1.SaveAs(Server.MapPath("~/images/") + FileUpload1.FileName);

ÉÏ´«²»³É¹¦ÊÇÕâ¸öÂð?
catch
{
this.Label1.Text = "ÎļþÉÏ´«²»³É¹¦£¡";
}
2013-08-02 07:39
·ÉÄêºÏ
Rank: 2
µÈ¡¡¼¶£ºÂÛ̳ÓÎÃñ
Ìû¡¡×Ó£º21
ר¼Ò·Ö£º50
×¢¡¡²á£º2013-7-29
ÊÕ²Ø
µÃ·Ö:3 
ÄãÉÏ´«ºó£¬ÔÚÄã±£´æµÄ·¾¶Ï¿´ÊÇ·ñÓÐÄãÉÏ´«µÄÎļþ£¬Èç¹ûûÓеĻ°£¬
°Ñ catch
                {
                    this.Label1.Text = "ÎļþÉÏ´«²»³É¹¦£¡";
                }

Óï¾ä¸Ä³É  catch (Exception ex)
                { this.Label1.Text = "ÎļþÉÏ´«²»³É¹¦¡£"; }
2013-08-06 11:41
¿ìËٻظ´£ºÎªÊ²Ã´Ö»Ö´ÐÐelseÓï¾ä£¿
Êý¾Ý¼ÓÔØÖÐ...
 
¡¡¡¡¡¡



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

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