1、在客户端可以将form用submit提交,如下: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="JS/jquery-1.3.2.js" type="text/javascript"></script> <script language="javascript" type="text/javascript"> function UpLoad() { $("#form1").submit(); } </script> </head> <body> <form id="form1" method="post" enctype="multipart/form-data" action="ImageHandler.ashx"> <div> <input id="File1" type="file" runat="server"/> <input id="Button1" type="button" value="上传" onclick="UpLoad()" /></div> <div id="imgList"></div> </form> </body> </html> 2、form表单需要加上属性method="post" enctype="multipart/form-data" 3、文件控件需要加上runat="server"属性
2、form表单需要加上属性method="post" enctype="multipart/form-data" 3、文件控件需要加上runat="server"属性
时间: 2024-10-29 19:05:30