📄 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 + -