日期:2014-05-20  浏览次数:20534 次

如何上传多张图片
在上传新闻的时候有时候需要上传多张图片,又同是要上传文字。请问个为高手,如何在asp.net   中上传多张图片并可控制图片的大小

------解决方案--------------------
if (FileUpload1.PostedFile.FileName != " ")
{

imagePath = FileUpload1.PostedFile.FileName;
imageType = imagePath.Substring(imagePath.LastIndexOf( ". ") + 1);

imageName = imagePath.Substring(imagePath.LastIndexOf( "\\ ") + 1);
if ( "jpg " != imageType && "gif " != imageType)
{
Response.Write( " <script> alert( '请选择jpg或gif格式的图片! '); </script> ");
return;
}
//到数据库中取出唯一标识
ImageSaveManager imageSaveManager = new ImageSaveManager();
ImageSave imageSave = new ImageSave();
imageSave.ImageName = imageName;
imageSave.ImageType = imageType;
imageSave.ImagePath = test;
imageSave.ImageAuthor = "0 ";// Tool.CurrentMember.CurrentMemberID;
imageSave.ImagePubDate = System.DateTime.Now.Date;
imageSaveManager.AddImageSave(imageSave);

string strCurrentImagePath = Server.MapPath(test) + "\\ " + imageSave.ID.ToString() + ". " + imageType;
FileUpload1.PostedFile.SaveAs(strCurrentImagePath);
if (this.ImageURL.Length <= 0)
{
this.ImageURL = test + "\\ " + imageSave.ID.ToString() + ". " + imageType;
this.ImageURLCount = 1;
}
else
{
this.ImageURL = ImageURL + "* " + test + "\\ " + imageSave.ID.ToString() + ". " + imageType;
this.ImageURLCount += 1;
}
this.lblPictureMessage.Text = " <font color= 'red '> 图片上传成功 </font> 你已经上传图片 " + this.ImageURLCount + "张,你可以继续上传图片! ";
// Response.Write( " <script> alert( '图片上传成功! '); </script> ");
}

这个可以上传多个