?? changeimage.aspx
字號:
<% @ Import Namespace="System.IO" %>
<% @ Import Namespace="System.Data" %>
<% @ Import Namespace="Packaging" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Language" content="zh-cn">
<title>照片更換</title>
<link rel="stylesheet" href="pack.css" type="text/css">
</head>
<body bgcolor=white onunload="opener.document.myform.photo.src=document._ctl0.fff.value">
<form enctype="multipart/form-data" method="post" runat=server>
<table cellpadding=0 cellspacing=1 width="300" border="0" align="center">
<tr align=center height=25>
<td><b>照片更換</b></td>
</tr>
<tr height=120>
<td>
<asp:Label width=100% id=myLabel text="可上傳文件類型:jpg、gif、png, 我們建議你選用width=300的照片上傳。" runat=server/><br><br>
選擇上傳照片:
<input type=file id=FileUp size=15 runat=server/>
<br><br>
<asp:Button id="Submit" text="上傳" onclick="Submit_OnClick" runat=server/>
<asp:Button id="fy" text="還原到默認卡通照片" onClick="fy_Click" runat="server" />
<br><asp:Label id="success" runat=server style="color:red" />
<asp:Panel id="fileinfo" runat=server Visible=False>
文件引用地址:<asp:label id=FName runat=server /><br>
文件大小:<asp:label id=FSize runat=server /><br>
文件類型:<asp:label id=FType runat=server />
</asp:Panel>
<input type=hidden name="fff" id="fff" runat="server"></td>
</tr>
</table>
</form>
</body>
</html>
<script language="VB" runat="SERVER">
Dim id As Integer
Sub Page_Load(Sender As Object, e As EventArgs)
Try
id=CInt(Request("id"))
Dim MyInfo As InfoDB=New InfoDB()
Dim fn As String
Dim DV As DataView=MyInfo.GetInfo(id)
If DV.Table.Rows.Count>0 Then
fff.value=DV.Table.Rows(0)("photo")
Else
success.Text="此Id不存在!"
End If
Catch
submit.visible=false
success.Text="對不起,我們不能允許你上傳!"
End Try
End Sub
Sub Submit_OnClick(Sender As Object, e As EventArgs)
If FileUp.PostedFile.ContentLength=0 Then
FileInfo.Visible=False
success.Text="上傳文件長度為0, 上傳失敗!"
Exit Sub
Else
FSize.Text=CStr(FileUp.PostedFile.Contentlength)
FType.Text=FileUp.PostedFile.ContentType
Dim fileSplit() As String=Split(FileUp.PostedFile.filename, "\")
Dim f As String
If FileUp.PostedFile.ContentType="image/pjpeg" Then
f=Server.MapPath("upload\photos\") + "photo" & id & ".jpg"
FName.Text="upload/photos/photos" & id & ".jpg"
ElseIf FileUp.PostedFile.ContentType="image/gif" Then
f=Server.MapPath("upload\photos\") + "photo" & id & ".gif"
FName.Text="upload/photos/photos" & id & ".gif"
Else
f=Server.MapPath("upload\photos\") + "photo" & id & ".png"
FName.Text="upload/photos/photos" & id & ".png"
End If
fileUp.PostedFile.SaveAs(f)
FileInfo.Visible=True
Dim MyInfo As InfoDB=New InfoDB()
MyInfo.ChangePhoto(id,f)
success.Text="照片更換成功!<br>"
fff.value=f
End If
End Sub
Sub fy_Click(Sender As Object, e As EventArgs)
Dim MyInfo As InfoDB=New InfoDB()
Dim fn As String
Dim DV As DataView=MyInfo.GetInfo(id)
If DV.Table.Rows.Count>0 Then
If DV.Table.Rows(0)("Gender")="女" Then
fn="images/girl.jpg"
MyInfo.ChangePhoto(id,fn)
Else
fn="images/boy.jpg"
MyInfo.ChangePhoto(id,fn)
End If
success.Text="照片已經復原!"
fileinfo.visible=false
fff.value=fn
Else
success.Text="此Id不存在!"
fileinfo.visible=false
End If
End Sub
</script>
<style>
td {
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size : 10pt;
}
.whiteB {
color: white;
font-weight : bold;
}
input {
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size : 10pt;
}
td.bar {
color: green; font-weight: bold;
}
a.whiteLink:link {
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
font-weight : bold;
color : white;
text-decoration : none;
}
a.whiteLink:visited {
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
font-weight : bold;
color : white;
text-decoration : none;
}
a.whiteLink:hover {
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
font-weight : bold;
color : white;
text-decoration : none;
}
a.barLink:link {
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
color : #CCFF99;
text-decoration : none;
}
a.barLink:visited {
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
color : #CCFF99;
text-decoration : none;
}
a.barLink:hover {
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
color : #CCFF99;
text-decoration : underline;
}
a.author:link {
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
color : black;
text-decoration : none;
}
a.author:visited {
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
color : black;
text-decoration : none;
}
a.author:hover {
font-family : Verdana, Geneva, Arial, Helvetica, sans-serif;
color : black;
text-decoration : underline;
}
</style>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -