jQuery Ajax File Upload实例源码

本文实例为大家分享了jQuery Ajax File Upload实例源码,供大家参考,具体内容如下

项目结构

Default.aspx
Upload.aspx
Scripts/…
style.css

效果图

jQuery Ajax File Upload实例源码_第1张图片 

客户端html代码

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="UploadFile.aspx.vb" Inherits="Web.UploadFile" %> 
 
 
 
 
   
   
   
   
   
 
 
  
Upload File
Upload File

     服务端处理代码Upload.aspx

     using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
     
    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) 
          { 
     
            Response.Write("fail"); 
          } 
        } 
      } 
    }
    
    

    以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

    你可能感兴趣的:(jQuery Ajax File Upload实例源码)