background image

byte[] data=newbyte[this.File1.PostedFile.ContentLength]; 

this.File1.PostedFile.InputStream.Read(data,0,this.File1.PostedFile.ContentLength); 

physicPath=upload.UpLoadAndSave(data,ref virPath,fext,physicPath); 

url=virPath; 

if(Session["PhotoUrl"]==null) 

ArrayList al=new ArrayList(); 
al.Add(physicPath); 
Session["PhotoUrl"]=al; 

else 

ArrayList al2=(ArrayList)Session["PhotoUrl"]; 

al2.Add(physicPath); 

Session["PhotoUrl"]=al2; 


catch(Exception ex) 

Response.Write("<script>alert('"+ex.Message+"');</script>"); 

// 如果要指定上传图片的大小,可以在调用该上传类前生成,见下面的实例:

try 

empPic = new Bitmap(File1.PostedFile.InputStream); 

catch 

Script.Alert(" 图片格式错误!" ); 
return false; 

Bitmap picSmall = new Bitmap(empPic,227,91); // 

 

生成图片大小

MemoryStream stream = new MemoryStream(); 

picSmall.Save(stream,ImageFormat.Jpeg); 
byte[] byteArray = stream.ToArray();