PHP数组相加操作及与array_merge的区别浅析
380
2024-01-10
本文实例为大家分享了jQuery Ajax File Upload实例源码,供大家参考,具体内容如下
项目结构
Default.aspx
Upload.aspx
Scripts/…
style.css
效果图
客户端html代码
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="UploadFile.aspx.vb" Inherits="Web.UploadFile" %> <!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> <link rel="Stylesheet" type="text/css" href="http://www.gimoo.net/t/1810/style.css" mce_href="style.css" media="all" /> <mce:script type="text/JavaScript" src="http://www.gimoo.net/t/Scripts/jQuery-1.4.1.min.js" mce_src="Scripts/jquery-1.4.1.min.js"></mce:script> <mce:script type="text/javascript" src="http://www.gimoo.net/t/Scripts/ajaxupload.3.5.js" mce_src="Scripts/ajaxupload.3.5.js"></mce:script> <mce:script type="text/javascript">< $(function () { var btnUpload = $('#upload'); var status = $('#status'); new AjaxUpload(btnUpload, { action: 'Upload.aspx', //Name of the file input box name: 'uploadfile', onSubmit: function (file, ext) { if (!(ext && /^(jpg|png|jpeg|gif)$/.test(ext))) { // check for valid file extension status.text('Only JPG, PNG or GIF files are allowed'); return false; } status.text('Uploading...'); }, onComplete: function (file, response) { //On completion clear the status status.text(''); //Add uploaded file to list if (response === "success") { $('<li></li>').appendTo('#files').html('<img src="http://www.gimoo.net/t/1810/uploads/' + file + '" mce_src="uploads/' + file + '" alt="" /><br />' + file).addClass('success'); } else { $('<li></li>').appendTo('#files').text(file).addClass('error'); } } }); }); // --></mce:script> </head> <body> <form id="form1" runat="server"> <div id="upload"> Upload File </div> < Upload Button--> <div id="Div1" >Upload File</div><span id="status" ></span> <List Files--> <ul id="files" ></ul> </form> </body> </html>
服务端处理代码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"); } } } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持绿夏网。
#免责声明#
本站[绿夏技术导航]提供的一切软件、教程和内容信息仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络收集整理,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。如果您喜欢该程序或内容,请支持正版,购买注册,得到更好的正版服务。我们非常重视版权问题,如有侵权请邮件[admin@lxwl520.com]与我们联系进行删除处理。敬请谅解!