All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
Web服务器IIS6的PHP最佳配置方法_php资料_编程技术
轻松实现无刷新三级联动菜单[VS2005与AjaxPro]_[Asp.Net教程]
DOTNET:LINQ与ADO.NET,3.0的创新_[Asp.Net教程]
SQL,Server与Oracle链接服务器应用_[SQL,Server教程]
.net中错误日志的写入_[Asp.Net教程]
ASP.NET中动态生成Xml格式文档,并转换为HTML文件_[Asp.Net教程]
asp.net2.0按比例生成图片的缩略图_[Asp.Net教程]
Sqlserver怎样将XML文件导入数据库_[SQL,Server教程]
学习网页制作认识XML的语法规则_[XML教程]
Delphi在状态栏中显示检查框实例
Reading number is top 10 pictures
Sora aoi on twitter5
29 the belle stars after bath figure3
壮丽的云彩1
色狗系列
这年头,找个靠谱的妹子太难了
人美胸美腿更美4
Discharge accidentally Actresses by the breast4
狗狗与主人神同步2
Angie Chiu vijara myth1
NeedWallpaper6
Download software ranking
The Bermuda triangle2
Boxer's Top ten classic battle3
Unix video tutorial2
天龙八部十二宫服务端
Tram sex maniac 2 (H) rar bag10
Ashlynn Video4
matrix3
网络管理员第三版
Professional killers2 data package
Unix video tutorial14
归海一刀 published in(发表于) 2014/1/30 0:59:39 Edit(编辑)
Asp.net实例:实现图片上传_[Asp.Net教程]

Asp.net实例:实现图片上传_[Asp.Net教程]

Asp.net实例:实现图片上传_[Asp.Net教程]























最近在学习asp.net,做了一个上传图片的小例子:如图:







在站点建一个上传图片的文件夹:upFiles




文件:upFile.aspx




<%@ Page Language="C#" AutoEventWireup="true" CodeFile="upFile.aspx.cs" Inherits="upFile" %>









上传图片







onClick="btnUpFile_Click" Text="上传" />



只能上传图片文件。












文件:upFile.aspx.cs




using System;
using System.Data;
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 upFile : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.img.Visible = false;
}
protected void btnUpFile_Click(object sender, EventArgs e)
{
string fullFileName = this.fileLoad.PostedFile.FileName;
string fileName = fullFileName.Substring(fullFileName.LastIndexOf("\\") + 1);
string typeFileName = fullFileName.Substring(fullFileName.LastIndexOf(".") + 1);
if (typeFileName == "jpg" || typeFileName == "gif" || typeFileName == "png")
{
this.fileLoad.SaveAs(Server.MapPath("upFiles") + "\\" + fileName);
this.img.ImageUrl = "upFiles/" + fileName;
this.img.Visible = true;
Response.Write ("上传成功");
}
else
{
Response.Write("");
}

}
}




可以实现简单的图片上传了,初学asp.net,写的不好,见笑了。




作者:无情 出处: 转载请注明出处














































添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.