|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
数据库有很多应用领域,但是如果你单单学数据库的话基本上做数据库管理员比较合适而已,跟领域结合的你还得再学习那些领域知识。(其实数据挖掘我真是不懂,本来这学期开了一门课了。asp.net|战略|上传比来做的项目跟ASP.NET上传文件内容有关,故将代码贴出,以便网友查阅,供应办理此类成绩思绪:如呈现任何不睬解成绩,请留言,实时帮您办理!
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Login.aspx.cs"Inherits="Login"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>::::上传办理体系::::</title>
</head>
<body>
<formid="form1"runat="server">
<divstyle="border-right:#ffff00thindashed;border-top:#ffff00thindashed;margin-bottom:4px;margin-left:55px;border-left:#ffff00thindashed;line-height:normal;margin-right:55px;padding-top:1px;border-bottom:#ffff00thindashed;letter-spacing:normal;position:static;background-color:silver;text-align:center">
<br/>
<asp:LabelID="LabelTitle"runat="server"Font-Bold="True"Font-Size="XX-Large"ForeColor="Black"
Text="上传办理"></asp:Label><br/>
<br/>
<asp:FileUploadID="FileUpload1"runat="server"Width="369px"/>
<asp:ButtonID="ButtonUp"runat="server"Height="21px"Text="上传"Width="67px"/><br/>
<br/>
<asp:LabelID="LabelTitle2"runat="server"ForeColor="Red"Text="*上传文件不克不及凌驾2M"></asp:Label><br/>
<b>原文件名:</b><spanid="FileName"runat="server"/><br/>
<b>上传到服务器:</b><spanid="SaveDir"runat="server"/><br/>
<b>缩略图地点:</b><spanid="sSaveDir"runat="server"/><br/>
<b>文件范例:</b><spanid="FileType"runat="server"/><br/>
<b>文件巨细:</b><spanid="FileLength"runat="server"/><br/>
<b>文件拓展名:</b><spanid="FileExtention"runat="server"/><br/>
<b>上传日期:<br/><spanid="UpDateTime"runat="server"/><br/>
图片预览:<br/>
<asp:ImageID="Image1"runat="server"ImageUrl="~/Login.aspx"BorderColor="#0000C0"/><br/>
</b>
<br/>
<br/>
</div>
</form>
</body>
</html>
********************************************************
usingSystem;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Collections;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
usingMWO.Model.Info;
usingMWO.DAL.Info;
publicpartialclassLogin:System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
}
protectedvoidButtonUp_Click(objectsender,EventArgse)
{
if(FileUpload1.PostedFile.FileName!=null)
{
try
{
FileName.InnerHtml=FileUpload1.PostedFile.FileName;//GetPhotoName
UpDateTime.InnerHtml=DateTime.Now.ToShortDateString();//UpDateTime
#regionSetPhotoSize
FileLength.InnerHtml=CountSize(FileUpload1.PostedFile.ContentLength);
if(FileUpload1.PostedFile.ContentLength>1024*1024*2)
{
Response.Write("<script>alert(图片不克不及凌驾划定巨细!);</script>");
}
else
{
#regionSetPhotoFormat
FileType.InnerHtml=FileUpload1.PostedFile.ContentType;
FileExtention.InnerHtml=System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName).ToUpper();
stringm_FileName="www.webjx.Com-"+DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-ffff").Replace(".","-")+FileExtention.InnerHtml;
stringm_sFileName="www.webjx.Com-"+DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-ffff").Replace(".","-")+FileExtention.InnerHtml;
if(FileExtention.InnerHtml==".JPG")
{
stringm_SavePath=Server.MapPath("./photo/")+m_FileName;
SaveDir.InnerHtml=m_SavePath;
#regionSetSmallPhoto
this.MakeSmallImg(FileUpload1.PostedFile,this.Server.MapPath("./SPhoto/")+m_sFileName,118,90);
stringm_sSavePath=this.Server.MapPath("./SPhoto/")+m_sFileName;
sSaveDir.InnerHtml=m_sSavePath;
#endregion
FileUpload1.PostedFile.SaveAs(m_SavePath);
Response.Write("<script>alert(图片文件保留乐成!);</script>");
#regionSaveDataBasee
PhotoInfom_PInfo=newPhotoInfo();
m_PInfo.Organization="5173";
m_PInfo.PicName=FileName.InnerHtml;
m_PInfo.ServerName="GLSDB";
m_PInfo.Cdate=DateTime.Now;
m_PInfo.Exp=FileExtention.InnerHtml;
m_PInfo.Flag=0;
m_PInfo.GameNickName="Bruce";//TextBox控件内容
m_PInfo.MoonStar=0;
m_PInfo.ShowIndex=0;
m_PInfo.SPicHttpAddr=m_sSavePath;
m_PInfo.Type=0;
m_PInfo.Vote=0;
m_PInfo.PicHttpAddr=m_SavePath;
PhotoDAOm_PDao=newPhotoDAO();
m_PDao.Insert(m_PInfo);
#endregion
}
else
{
Response.Write("<script>alert(图片格局不准确,请选择图片文件!);</script>");
}
#endregion
}
#endregion
}
catch(Exceptionm_Ex)
{
Response.Write("<script>alert("+m_Ex.ToString()+");</script>");
}
}
elseif(FileUpload1.PostedFile.FileName=="")
{
Response.Write("<script>alert(上传文件不克不及为空!);</script>");
}
}
#region
///<summary>
///盘算文件巨细函数,Size为字节巨细
///</summary>
///<paramname="Size">初始文件巨细</param>
///<returns></returns>
publicstringCountSize(longSize)
{
stringm_strSize="";
longFactSize=0;FactSize=Size;
if(FactSize<=1024)
m_strSize=FactSize.ToString()+"Byte";
if(FactSize>=1024&&FactSize<=1048576)
m_strSize=(FactSize/1024).ToString()+"K";
if(FactSize>=1048576&&FactSize<=10485760)
m_strSize=(FactSize/1024/1024).ToString()+"M";
returnm_strSize;
}
#endregion
#regionSaveSmallPhoto
///<summary>
///高明晰缩略图算法
///</summary>
///<paramname="postFile">图片文件工具</param>
///<paramname="saveImg">要保留为缩略图的源文件</param>
///<paramname="Width">宽度</param>
///<paramname="Height">高度</param>
publicvoidMakeSmallImg(System.Web.HttpPostedFilepostFile,stringsaveImg,System.DoubleWidth,System.DoubleHeight)
{
//SourcePhotoName
stringm_OriginalFilename=postFile.FileName;
stringm_strGoodFile=saveImg;
//GetPhotoObjectFromSourceFile
System.Drawing.Imagem_Image=System.Drawing.Image.FromStream(postFile.InputStream,true);
System.DoubleNewWidth,NewHeight;
if(m_Image.Width>m_Image.Height)
{
NewWidth=Width;
NewHeight=m_Image.Height*(NewWidth/m_Image.Width);
}
else
{
NewHeight=Height;
NewWidth=(NewHeight/m_Image.Height)*m_Image.Width;
}
if(NewWidth>Width)
{
NewWidth=Width;
}
if(NewHeight>Height)
{
NewHeight=Height;
}
//GetPhotoSize
System.Drawing.Sizesize=newSystem.Drawing.Size((int)NewWidth,(int)NewHeight);
//TheNewofBimpPhoto
System.Drawing.Imagebitmap=newSystem.Drawing.Bitmap(size.Width,size.Height);
//TheNewofPalette
System.Drawing.Graphicsg=System.Drawing.Graphics.FromImage(bitmap);
//SetHightQualityArithmeticForGraphics
g.InterpolationMode=System.Drawing.Drawing2D.InterpolationMode.High;
//设置高质量,低速率出现光滑水平
g.SmoothingMode=System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//ClearCanvas
g.Clear(System.Drawing.Color.White);
//在指定地位绘图
g.DrawImage(m_Image,newSystem.Drawing.Rectangle(0,0,bitmap.Width,bitmap.Height),
newSystem.Drawing.Rectangle(0,0,m_Image.Width,m_Image.Height),
System.Drawing.GraphicsUnit.Pixel);
//SavePhotoOfHightFocus
bitmap.Save(m_strGoodFile,System.Drawing.Imaging.ImageFormat.Jpeg);
//DisposeRes
g.Dispose();
m_Image.Dispose();
bitmap.Dispose();
}
#endregion
}
效率会有不少的变化。而实际上java是基于堆栈机器来设计,这和我们常见的基于寄存器的本地机器是差异比较大的。总体来说,这是一种虚拟机的设计思路。 |
|