本文实例为大家分享了jQuery Ajax File Upload实例源码,供大家参考,具体内容如下
项目结构
Default.aspx Upload.aspx Scripts/… style.css
效果图
客户端HTML代码
<!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">
' + file).addClass('success'); } else { $('').appendTo('#files').text(file).addClass('error'); } } }); });
// --></mce:script>
服务端处理代码Upload.aspx
namespace JqueryAjaxUploadTest
{
public partial class Upload : System.Web.UI.Page
{
protected void Page_Load(object sender,EventArgs e)
{
try
{
HttpPostedFile hpfFile = Request.Files["uploadfile"];
hpfFile.SaveAs(Server.MapPath("~/uploads/") + hpfFile.FileName);
Response.Write("success");
}
catch (Exception)
{
{
public partial class Upload : System.Web.UI.Page
{
protected void Page_Load(object sender,EventArgs e)
{
try
{
HttpPostedFile hpfFile = Request.Files["uploadfile"];
hpfFile.SaveAs(Server.MapPath("~/uploads/") + hpfFile.FileName);
Response.Write("success");
}
catch (Exception)
{
Response.Write("fail");
}
}
}
}