页面代码主要就是JS
view plaincopy to clipboardprint
复制代码 代码如下:
<head runat="server">
<title>无标题页</title>
<mce:script language="javascript" type="text/javascript"><!--
function Imagesrc()
{
document.getElementById("image").src=document.all.FileUpload1.value;
}
// --></mce:script>
</head>
<body>
<form id="form1" runat="server">
<div>
<img alt="\" id="image" style="height:50px;width:50px" />
<asp:FileUpload ID="FileUpload1" runat="server" onchange="Imagesrc()" />
<br />
<asp:Button ID="btnPost" runat="server"
Text="上传" OnClick="btnPost_Click" /></div>
</form>
</body>
<head runat="server">
<title>无标题页</title>
<mce:script language="javascript" type="text/javascript"><!--
function Imagesrc()
{
document.getElementById("image").src=document.all.FileUpload1.value;
}
// --></mce:script>
</head>
<body>
<form id="form1" runat="server">
<div>
<img alt="\" id="image" style="height:50px;width:50px" />
<asp:FileUpload ID="FileUpload1" runat="server" onchange="Imagesrc()" />
<br />
<asp:Button ID="btnPost" runat="server"
Text="上传" OnClick="btnPost_Click" /></div>
</form>
</body>
defualt.aspx.cs代码
view plaincopy to clipboardprint
复制代码 代码如下:
protected void btnPost_Click(object sender, EventArgs e)
{
string PostName = Server.MapPath("Image");
string fileName = FileUpload1.FileName;
//是否包含此文件
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(PostName "/" fileName);
}
}
view plaincopy to clipboardprint
复制代码 代码如下:
<head runat="server">
<title>无标题页</title>
<mce:script language="javascript" type="text/javascript"><!--
function Imagesrc()
{
document.getElementById("image").src=document.all.FileUpload1.value;
}
// --></mce:script>
</head>
<body>
<form id="form1" runat="server">
<div>
<img alt="\" id="image" style="height:50px;width:50px" />
<asp:FileUpload ID="FileUpload1" runat="server" onchange="Imagesrc()" />
<br />
<asp:Button ID="btnPost" runat="server"
Text="上传" OnClick="btnPost_Click" /></div>
</form>
</body>
<head runat="server">
<title>无标题页</title>
<mce:script language="javascript" type="text/javascript"><!--
function Imagesrc()
{
document.getElementById("image").src=document.all.FileUpload1.value;
}
// --></mce:script>
</head>
<body>
<form id="form1" runat="server">
<div>
<img alt="\" id="image" style="height:50px;width:50px" />
<asp:FileUpload ID="FileUpload1" runat="server" onchange="Imagesrc()" />
<br />
<asp:Button ID="btnPost" runat="server"
Text="上传" OnClick="btnPost_Click" /></div>
</form>
</body>
defualt.aspx.cs代码
view plaincopy to clipboardprint
复制代码 代码如下:
protected void btnPost_Click(object sender, EventArgs e)
{
string PostName = Server.MapPath("Image");
string fileName = FileUpload1.FileName;
//是否包含此文件
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(PostName "/" fileName);
}
}
标签:
文件,本地,路径
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“asp.net实现上传文件显示本地绝对路径的实例代码”评论...