国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

利用vb實現圖片上傳

2024-07-21 02:21:02
字體:
來源:轉載
供稿:網友
中國最大的web開發資源網站及技術社區,
<script language="vb" runat="server">
sub uploadfile(sender as object, e as eventargs)

if fileup.postedfile.contentlength = 0 then
fileinfo.visible = false
exit sub
else
fileinfo.visible = true
fdisplay1.visible = true
end if

fsize.text ="上傳文件大小"+ cstr(fileup.postedfile.contentlength/1024)+"kb"
fname.text = "已上傳文件名:"+fileup.postedfile.filename+"<br>"+fname.text

'寫入數據庫
on error resume next
dim myconn as sqlconnection
dim mycomm as sqlcommand
dim sql as string
dim id as integer
dim image,anewimage as system.drawing.image
dim width,height,newwidth,newheight as integer
dim callb as system.drawing.image.getthumbnailimageabort
myconn=new sqlconnection(configurationsettings.appsettings("數據庫"))
myconn.open()
sql="insert into picture (姓名,班級,介紹,屬性) values ('"&request.cookies("dgxyl").values("dgxylname")&"','"&request.cookies("dgxyl").values("dgxylbj")&"','"&trim(request("textbox1"))&"','"&request("r1")&"')"
mycomm=new sqlcommand(sql,myconn)
mycomm.executenonquery()
myconn.close()

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='http://www.163design.net/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>
<html>
<body bgcolor=white>
<h3 align="center">請正確填寫下面各項</h3>
<hr></h3>
<div id="fileinfo" visible="false" runat="server">
<asp:label id="fsize" runat="server"/><br>
<asp:label id="fname" runat="server"/><br>
<asp:label id="fdisplay" runat="server"/>
<asp:label id="fdisplay1" runat="server"/>
</div>
<form enctype="multipart/form-data" onsubmit="return guestbook_validator(this)" runat="server">
上傳文件
<input type="file" id="fileup" runat="server" size="20"><br>
圖片屬性:<input type="radio" value="<%=request.cookies("dgxyl").values("dgxylbj")%>" name="r1" checked>本班<input type="radio" value="全校" name="r1">全校(本班則只在本班顯示,全校則在全校顯示)<p>
圖片說明:<br>
<asp:textbox id="textbox1" runat="server" width="233px" height="141px">
</asp:textbox>
<asp:requiredfieldvalidator id="requiredfieldvalidator1" runat="server" controltovalidate="textbox1" errormessage="請輸入圖片說明">
</asp:requiredfieldvalidator><br>
<asp:button id="upload" onclick="uploadfile" text="上傳圖片" runat="server"/>
</form>
<hr>
<p>注意:</p>
<ol>
<li><b>嚴禁上傳污染環境的照片,否則賬號將被刪除!</b></li>
<li><font color="#808000"><b>請詳細填寫照片說明,圖片說明不詳細將會被視為亂傳圖片,將會被刪除!</b></font></li>
</ol>
<p> </p>

</body>
</html>



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宁乡县| 舒兰市| 扶余县| 开化县| 乐清市| 绥滨县| 巢湖市| 柳江县| 潢川县| 朔州市| 溧阳市| 莎车县| 七台河市| 天津市| 长白| 涡阳县| 余姚市| 邵东县| 新化县| 丹巴县| 望城县| 扎鲁特旗| 儋州市| 四川省| 长海县| 彭阳县| 大宁县| 文成县| 上饶市| 古浪县| 全南县| 安宁市| 全椒县| 紫金县| 青神县| 陆川县| 新津县| 九龙坡区| 开远市| 彰武县| 新化县|