发给你一个上传图片并把它存入数据库的例子。
1.前台
2.后台
using System.IO;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
try
{
if (this.FileUpload1.PostedFile.FileName != "")
{
string ImgPath = FileUpload1.PostedFile.FileName;
string ImgName = ImgPath.Substring(ImgPath.LastIndexOf("\\") + 1);
string ImgExtend = ImgPath.Substring(ImgPath.LastIndexOf(".") + 1);
int FileLen = this.FileUpload1.PostedFile.ContentLength;
Byte[] FileData = new