首页 新闻 会员 周边 捐助

请教,关于jquery.uploadify ​3​.​1 无法多文件多个文件上传

0
悬赏园豆:20 [待解决问题]

在网上找了篇jquery.uploadify  ​3​.​1 例子,学着做起来发现无法多文件上传,multi属性已经设为true了

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UpLoad.aspx.cs" Inherits="Web.Component.Attachment_New.UpLoad" %>

<!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 href="AjaxUpload/uploadify.css" rel="stylesheet" type="text/css" />
    <script src="AjaxUpload/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="AjaxUpload/jquery.uploadify-3.1.min.js" type="text/javascript"></script>
     <script type="text/javascript">

         $(function () {
             $("#uploadify").uploadify({

                 'swf': 'AjaxUpload/uploadify.swf',
                 'uploader': 'AjaxUpload/UpLoad.ashx',
                 'cancelImg': 'AjaxUpload/cancel.png',
                 'queueID': 'fileQueue',
                 'buttonText': '选择文件',
                 'fileDesc': '*.jpg;*.gif;*.avi;*.doc;*.rmvb;*.wav;*.mp3;*.zip;*.rar;*.xls;*.xlsx;*.txt;*.ppt;*.pdf;*.jpeg;*.bmp;*.flv;*.doc;*.docx;',
                 'fileExt': '*.jpg;*.gif;*.avi;*.doc;*.rmvb;*.wav;*.mp3;*.zip;*.rar;*.xls;*.xlsx;*.txt;*.ppt;*.pdf;*.jpeg;*.bmp;*.flv;*.doc;*.docx;',
                  'auto':false,
                  'multi': true,


                 'onUploadSuccess': function (file, data, response) {
                     $('#' + file.id).find('.data').html(' 上传完毕');
                     document.getElementById('hfReturnValue').value = data; //有上传成功才刷新这窗口的父窗口
                 }

             });
         });  

         //上传资源文件
        function UploadFile() {
            var ret = window.showModalDialog("Upload.aspx?Code=Resource", "dialogWidth=600px;dialogHeight=500px;status=no;help=no");
        }
        onunload = function () {
            window.returnValue = document.getElementById("hfReturnValue").value;
         }

    </script>
    <style type="text/css">
      /* 按钮 */
input.button
{

   background-color:Black;
   color:White;
    height:30px;
    width:110px;
    cursor:hand;
 
}

    </style>
</head>
<body>

    <div>
    <input id="hfReturnValue" type="hidden" runat="server" />
     <table>
     <tr>
     <td colspan="2" style=" height:20px"></td>
         </tr>
     <tr>
    <td  style=" width:100px; padding: 0 0 1px 9px">
     <input type="file" name="uploadify" id="uploadify"  />
     </td>
     <td valign="bottom" align="right" style=" padding: 0 0 0 15px; font-weight:bold;" >
        <a href="javascript:$('#uploadify').uploadify('upload')">上传</a>&nbsp;|&nbsp;<a href="javascript:$('#uploadify').uploadify('cancel')">取消上传</a>
        </td>
      </tr>
     </table>
        <div id="fileQueue" style=" padding: 0 0 0 10px;"></div>
    </div>


</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using Anole.Common;
using Anole.Attachment.Model;
using Anole.Attachment.IDAL;
using Anole.Attachment.DALFactory;


namespace Web.Component.Attachment_New.AjaxUpload
{
    /// <summary>
    /// UpLoad 的摘要说明
    /// </summary>
    public class UpLoad : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpPostedFile oFile = context.Request.Files["Filedata"];
            if (oFile != null)
            {
                string uploadpath = HttpContext.Current.Server.MapPath(@"..\..\..\" + Web.UI.HostPage.GetFormalUploadPath("ResourcePath"));
                if (!Directory.Exists(uploadpath))
                {
                    Directory.CreateDirectory(uploadpath);
                }
                string sOriginallyFileName = oFile.FileName;
                string sFileExt = Utils.GetFileExtension(sOriginallyFileName);
                string sCurrentlyFileName = Guid.NewGuid() + "." + sFileExt;
                oFile.SaveAs(uploadpath + sCurrentlyFileName);
                string fileIdStr = "";
                if (HttpContext.Current.Cache["attachmenttemp"] != null)
                {
                    fileIdStr = HttpContext.Current.Cache["attachmenttemp"].ToString();
                }
                AttachmentInfo attachmentinfo = new AttachmentInfo();
                attachmentinfo.AttachmentClassID = int.Parse(Web.UI.HostPage.GetAppSettings("Resource:Class"));
                attachmentinfo.CurrentlyFileName = sCurrentlyFileName;
                attachmentinfo.OriginallyFileName = sOriginallyFileName;
                attachmentinfo.FileAttachment = uploadpath;
                attachmentinfo.Extension = sFileExt;
                attachmentinfo.FileSize = oFile.ContentLength;
                attachmentinfo.DateCreated = DateTime.Now;
                attachmentinfo.IsSavetoDisk = true;
                IAttachmentDAL dal = AttachmentFactory.Create();
                int attachmentid = dal.InsertAttachmentInfo(attachmentinfo);
                if (attachmentid > 0)
                {
                    fileIdStr += attachmentid.ToString() + ",";
                }
                HttpContext.Current.Cache["attachmenttemp"] = fileIdStr;
                context.Response.Write("1");
               
            }
            else
            {
                context.Response.Write("0"); 

            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
Sureboy的主页 Sureboy | 菜鸟二级 | 园豆:212
提问于:2014-07-14 10:13
< >
分享
所有回答(1)
0

不应该啊,我想还是你配置的问题。

jquery.uploadify ​3​.​1 是支持文件上传,无法实现多文件上传的情况有可能是浏览器问题。http://www.cnblogs.com/mbailing/archive/2011/03/30/uploadify.html

你看看这个,希望对你有用。

jerry-Tom | 园豆:4077 (老鸟四级) | 2014-07-14 16:46
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册