<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "_ default" %>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "<a href =" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "target =" _ blank "> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd </a>">
<HTML>
<Head runat = "server">
<Title> untitled page </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Asp: fileupload id = "fileupload1" runat = "server"/>
<Asp: button id = "button1" runat = "server" onclick = "button#click" text = "button"/>
<Asp: regularexpressionvalidator id = "regularexpressionvalidator1" runat = "server" controltovalidate = "fileupload1"
Errormessage = "must be a jpg or GIF file" validationexpression = "^ ([A-Za-Z] :) | (\ {2} \ W +) \ $ ?) (\ W [\ W]. * ))((.jpg |. jpg |. gif |. GIF) $ "> </ASP: regularexpressionvalidator>
</Form>
</Body>
</Html>
Using system;
Using system. Data;
Using system. Data. SQL;
Using system. configuration;
Using system. collections;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Public partial class _ default: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
}
Protected void button#click (Object sender, eventargs E)
{
String savepath = @ "F: \ wwwroot \ cookie \ temp \";
If (fileupload1.hasfile)
{
String filename;
Filename = fileupload1.filename;
Savepath + = filename;
Fileupload1.saveas (savepath );
Page. response. Write (fileupload1.postedfile. contenttype + fileupload1.postedfile. contentlength );
}
Else
{
Page. response. Write ("fff ");
}
}
}