using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.IO;
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 _Default : System.Web.UI.Page
{
string v;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
TextBox1.Text = v;
HttpFileCollection uploadFilCol = Request.Files;
for (int i = 0; i < uploadFilCol.Count; i++)
{
HttpPostedFile file = uploadFilCol[i];
string fileExt = Path.GetExtension(file.FileName).ToLower();
string fileName = Path.GetFileName(file.FileName);
if (fileName != string.Empty)
{
try
{
if (fileExt == ".jpg" || fileExt == ".gif")
{
file.SaveAs(Server.MapPath("./Images/") +"bensoft"+ fileName);
}
else
{
file.SaveAs(Server.MapPath("./Others/") + fileName);
}
}
catch (Exception ex)
{
throw ex;
}
}
}
}
}
//*************************************************
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET
7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript" type="text/javascript">
// <!CDATA[
function FileUpload2_onclick() {
}
function FileUpload1_onclick() {
}
// ]]>
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 280px;
POSITION: absolute; TOP: 101px" runat="server" Text="ÊÍãíá ÇáãáÝ Ãæ ÇáÕæÑÉ"
onclick="Button1_Click1" />
<div id="Div1" runat="server" style="Z-INDEX:102;LEFT:165px;WIDTH:1026px;
POSITION:absolute;TOP:7px;HEIGHT:19px">
<INPUT id="FileUpload1" style="WIDTH: 389px; HEIGHT: 22px"
type="file" size="45" runat="server" onclick="return FileUpload1_onclick()">
<asp:Label id="Label1" runat="server" Width="598px"
ForeColor="Red" />
</div>
<div id="Div2" runat="server" style="Z-INDEX:103;LEFT:166px;WIDTH:1026px;
POSITION:absolute;TOP:38px;HEIGHT:19px">
<INPUT style="WIDTH: 389px; HEIGHT: 22px" type="file"
size="45" runat="server" id="FileUpload2" onclick="return FileUpload2_onclick()">
<asp:Label id="Label2" runat="server" Width="357px"
ForeColor="Red" />
</div>
<div id="Div3" runat="server" style="Z-INDEX:104;LEFT:166px;WIDTH:1026px;
POSITION:absolute;TOP:68px;HEIGHT:19px">
<INPUT style="WIDTH: 377px; HEIGHT: 22px" type="file"
size="45" runat="server" id="FileUpload3">
<asp:Label id="Label3" runat="server" Width="361px"
ForeColor="Red" />
</div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</form>
</body>
</html>