<%@ page language="java" contentType="text/html; charset=GB2312" pageEncoding="GB2312"%>
<%@ page language="java" import="javaio"%>
<%@ page language="java" import="comjspsmartupload"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 401 Transitional//EN">
<html>
<head>
<meta >我做了个例子给你
前台:
<div>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server"
Text="Button" onclick="Button1_Click" />
<asp:Image ID="Image1" runat="server" />
</div>
后台:
protected void Button1_Click(object sender, EventArgs e)
{
FileUpload1SaveAs(ServerMapPath("img/"+FileUpload1FileName));//上传
Image1ImageUrl = "~/img/" + FileUpload1FileName;//路径(将这个数据保存到数据库就可以了。img为项目里一个文件夹的名称)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)