C#中上传图片

来源:百度知道 编辑:UC知道 时间:2024/05/13 02:31:34
上传的图片是保存在文件里的,,能支持所有图片格式,还能生成缩图,并能自动给这个图片生成一个名字 .
sxlfxiaojuan 完整的程序 要是网页的

连水印一起了.自己弄张水印图片.
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;
using System.Data.SqlClient;
using System.IO;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string fileContentType = FileUpload1.PostedFile.ContentType;
if (fileContentType == "image/bmp" || fileContentType == "image/gif" || fileContentType == "image/pjpeg")
{
string name = FileUpload1.PostedFile.FileName; //