人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統(tǒng)下載站 > 技術(shù)開發(fā)教程 > 詳細頁面

asp.net上傳圖片并一起生成縮略圖

asp.net上傳圖片并一起生成縮略圖

更新時間:2022-09-10 文章作者:未知 信息來源:網(wǎng)絡(luò) 閱讀次數(shù):

<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

'寫入數(shù)據(jù)庫
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("數(shù)據(jù)庫"))
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='/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("你已經(jīng)提交了留言,請等待服務(wù)器應(yīng)答!");
  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>嚴禁上傳污染環(huán)境的照片,否則賬號將被刪除!</b></li>
  <li><font color="#808000"><b>請詳細填寫照片說明,圖片說明不詳細將會被視為亂傳圖片,將會被刪除!</b></font></li>
</ol>
<p> </p>

</Body>
</Html>

 

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統(tǒng)下載排行

網(wǎng)站地圖xml | 網(wǎng)站地圖html
主站蜘蛛池模板: 福州市| 南平市| 长沙县| 叶城县| 建德市| 惠水县| 库尔勒市| 东明县| 陈巴尔虎旗| 正阳县| 灵台县| 寿光市| 麟游县| 灵川县| 昔阳县| 肥东县| 德昌县| 保德县| 迁安市| 洛南县| 大厂| 安国市| 正定县| 溧阳市| 阳谷县| 封丘县| 永宁县| 普安县| 苍南县| 义乌市| 福鼎市| 囊谦县| 冷水江市| 汽车| 稷山县| 京山县| 长沙市| 婺源县| 社会| 鄂尔多斯市| 朝阳县|