页面代码:
NOTE:需要jquery插件(Uploadify)下载地址:uploadify下载
<%@ Page Language="C#" CodeBehind="AsynchronousUpload.aspx.cs"
Inherits="Example.AsynchronousUpload" %>
<!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="Scripts/uploadify-v2.1.4/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="Scripts/uploadify-v2.1.4/jquery.uploadify.v2.1.4.js" type="text/javascript"></script>
<script src="Scripts/uploadify-v2.1.4/jquery.uploadify.v2.1.4.min.js" type="text/javascript"></script>
<script src="Scripts/uploadify-v2.1.4/swfobject.js" type="text/javascript"></script>
<link href="Scripts/uploadify-v2.1.4/uploadify.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready(function () {
$("#uploadify").uploadify({
'uploader': 'Scripts/uploadify-v2.1.4/uploadify.allglyphs.swf',
'script': 'handler/upHandle.ashx',
'cancelImg': 'Scripts/uploadify-v2.1.4/cancel.png',
'folder': 'UpFile', //上传文件路径
'queueID': 'fileQueue',
'auto': false, //是否需要点击上传才上传文件
'multi': false, //是否允许上传多个文件
'fileDesc': '请选择图片类型',
'fileExt': '*.jpg',
'sizeLimit': '1048576', //限制大小1M
onComplete: function (evt, queueID, fileObj, response, data) {
alert(response);
}