int fileLen = 0;
try
{
fileLen = ful_Photo.PostedFile.ContentLength;//获?取¨?上¦?传ä?文?件t大䨮小?
}
catch { }
if (fileLen > 0 && fileLen < 204800)
{
byte[] fileData = new Byte[fileLen];
HttpPostedFile hp = ful_Photo.PostedFile;
Stream sr = hp.InputStream;
sr.Read(fileData, 0, fileLen);
model.Titel = tb_titel.Text;
model.Content = tb_Content.Text;
model.Image = fileData;
string add = this.ful_Photo.PostedFile.FileName;
if (bll.Create(model) >= 1)
{
string address = Server.MapPath("temp");
System.IO.File.Delete(address + @"\0.jpg ");
FileStream fs = new FileStream(address + @"\0.jpg ", FileMode.OpenOrCreate, FileAccess.Write);
int ArraySize = new int();
ArraySize = fileData.GetUpperBound(0);
fs.Write(fileData, 0, ArraySize);
fs.Close();
im_Photo.ImageUrl = "~/Test/temp/0.jpg";
}
}
else
{
JScript.Alert("上¦?传ä?图ª?片?不?能¨¹大䨮于®¨²200K");
}