Dim myCommand As New SqlCommand("select top 1 id from picture order by id desc", myConn) myCommand.Connection.Open() Dim myReader As SqlDataReader=mycommand.executereader() if myReader.Read() then id=myReader("id") end if myconn.close() '保存图片 FileUp.PostedFile.SaveAs( Server.MapPath("\classpic\")&cstr(id)&".jpg" ) '生成缩略图 image=System.Drawing.Image.FromFile(Server.MapPath("/classpic/"+cstr(id)+".jpg")) width=image.Width height=image.height if width>height then newwidth=250 newheight=image.height/image.Width*newwidth else newheight=250 newwidth=image.Width/image.height*newheight end if response.write("id="+cstr(id)+"width="+cstr(Width)+";height="+cstr(height)+" ") response.write("newwidth="+cstr(newwidth)+";newheight="+cstr(newheight)+"<br>")
aNewImage=image.GetThumbnailImage(newwidth,newheight,callb,new System.IntPtr()) aNewImage.Save(Server.MapPath("/smallpic/"+cstr(id)+".jpg")) image.Dispose()
Dim FileSplit() As String = Split( FileUp.PostedFile.FileName, "\" ) Dim FileName As String = FileSplit(FileSplit.Length-1) Dim Exts() As String = Split( FileName, "." ) Dim Ext As String = LCase(Exts(Exts.Length-1))
FDisplay.Text = "<A Target='_blank' HREF='/classpic/"&cstr(id)&".jpg"& "'>查看上传文件</A>" FDisplay1.text="<a href='/picture/default.asp?bj="&cstr(request.cookies("dgxyl").values("dgxylbj"))&"'>返回</a>" End Sub </script> <SCRIPT language=JavaScript> <!-- var requestsubmitted=false; function guestbook_Validator(theForm) { //检查是否从新提交 if (requestsubmitted==true){ alert("你已经提交了留言,请等待服务器应答!"); return(false); } requestsubmitted=true;
return (true); } //--> </SCRIPT>
|