日期:2014-05-17 浏览次数:20554 次
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>无标题页</title>
<link href="http://www.svnhost.cn/style/public.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script language="javascript">
function $(o){return document.getElementById(o);}
function CheckImgCss(o,img)
{
if (!/\.((jpg)|(bmp)|(gif)|(png))$/ig.test(o.value))
{
alert('只能上传jpg,bmp,gif,png格式图片!');
o.outerHTML = o.outerHTML;
}
else
{
$(img).filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src=o.value;
//$('Image1').src = o.value;//这里IE7已经不支持了。所以才有上面的方法。
}
}
</script>
<form id="form1" runat="server">
<div><h1>一次上传多个图片并预览,请选择图片:</h1>
<br />
<asp:FileUpload ID="FileUpload1" onchange="CheckImgCss(this, 'img');" runat="server" />
<br />
<asp:FileUpload ID="FileUpload2" onchange="CheckImgCss(this, 'img');" runat="server" />
<br />
<asp:FileUpload ID="FileUpload3" onchange="CheckImgCss(this, 'img');" runat="server" />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="上传" />
<div id="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=<%= pic%>,sizingMethod=scale);width:102px;height:100px;"></div>
</div>
</form>
<div>
</body>
</html>
------解决方案--------------------
swfupload还是flashupload。
bbs.ahnw.gov.cn,去看看吧,这个论坛用了flash的多文件上传。但是我发现它只兼容IE。
------解决方案--------------------
good luck
------解决方案--------------------
给你一段ajax无刷新上传的代码
<%@ WebHandler Language="c#" Class="File_WebHandler" Debug="true" %>
using System;
using System.Web;
using System.IO;
//51aspx
public class File_WebHandler : IHttpHandler
{
private const int UploadFileLimit = 3;//上传文件数量限制
private string _msg = "上传成功!";//返回信息
public void ProcessRequest(HttpContext context)
{
string user = context.Request.UrlReferrer.ToString();
int iTotal = context.Request.Files.Count;
if (iTotal == 0)
{
_msg = "没有数据";
}
else
{
int iCount = 0;
for (int i = 0; i < iTotal; i++)
{
HttpPostedFile file = context.Request.Files[i];
if (file.ContentLength > 0 || !str