怎么解决啊JSuploadify

解决方案 »

  1.   

     <a href="###" class="btn" id="upload" style="float: none; display: inline-block;margin: 0px;">上传附件</a>
                                        <input type="hidden" name="wholedir" value="" class="wholedir" />
                                        <span class="filelist"></span> var uploadBind = function () {
            $('#upload').unbind('click').bind('click', function () {
                var html = '<div id="filepart" class="alerter_oneL"><div class="alerter_input1">文件上传:<input type="file" id="fileupload" /></div><div id="filequeue"></div><div class="alerter_btn"><a href="###" id="startUploadLink">上传</a><a href="###" id="clearQueueLink">取消</a></div></div>';
                ocean.alerter_on(html, 'alerter3', 'body');
                if ($("#fileuploadUploader").length != 0) {
                    $("#fileupload").remove();
                    $("#fileuploadUploader").remove();
                    $('#filequeue').before('<input type="file" id="fileupload" />');
                    $("#startUploadLink").remove();
                    $('#filequeue').after('<a href="###" id="startUploadLink">上传</a>');
                    $('#filequeue').empty();
                    $("#clearQueueLink").remove();
                    $("#startUploadLink").after('<a href="###" id="clearQueueLink">取消</a>');
                }
    //            var uploadfolderid = AjaxServer.Ajax.GetUploadFolder(1449).value;
                $("#fileupload").uploadify({
                    'uploader': 'uploadify/uploadify.swf',
                    'script': 'UploadHandler.ashx',
                    'cancelImg': 'uploadify/cancel.png',
                    'folder': 'UploadFile',
    //                'scriptData': { 'folderID': uploadfolderid, 'note': '', 'userName': userName, 'userName_EncryptCookie': userName_EncryptCookie, 'userID': userID },
                    'multi': true,
                    'auto': false,
                    'queueID': 'filequeue',
                    'onAllComplete': function (event, data) {
                        $("#fileuploadUploader").css("visibility", "inherit");
                        $("#filepart").hide();
                        if (errormsg.length > 0) {
                            ocean.errorAlerter(errormsg);
                        }
                        else {
                            var msg = '';
                            if (data.errors > 0) {
                                msg = "<p>共上传文件" + data.filesUploaded + "个," + data.errors + "个失败</p>";
                            }
                            else {
                                msg = "<p>上传成功</p>"
                            }
                            ocean.alerter_off();
                            ocean.errorAlerter(msg);
                        }
                        showfilelist();
                    },
                    'onComplete': function (event, queueId, fileObj, response, data) {
                        if (response.indexOf('Error') > -1) {
                            errormsg += response;
                        }
                        else {
                            fileidlist += response + ',';
                        }
                    }
                });
                $("#startUploadLink").click(function () {
                    $("#fileupload").uploadifyUpload();
                });
                $("#clearQueueLink").click(function () {
                    $("#fileupload").uploadifyClearQueue();
                    ocean.alerter_off();
                });
            })
        }ashx文件应该没问题
      

  2.   

    我感觉是你response contentType的问题
      

  3.   

    我觉得,是你的服务器问题,MIME 设置可能不支持png扩展名,你换个扩展名试试就能验证我的猜测了
      

  4.   

    我把png的图片都改成gif了但是还是一样
      

  5.   

    你上传文件的类型是uploadify设置允许的类型吗
      

  6.   

    txt应该可以把,word文档也不行
      

  7.   

    txt应该可以把,word文档也不行贴一下你的uploadify配置文件
      

  8.   

    txt应该可以把,word文档也不行贴一下你的uploadify配置文件
      

  9.   

    我下uploadify,发现没配置文件,是在UploadHandler.ashx中判断文件类型。贴一下你的UploadHandler.ashx吧
      

  10.   

    using System;
    using System.Web;
    using System.IO;
    using System.Linq;
    using System.Collections.Generic;public class UploadHandler : IHttpHandler {
        
        public void ProcessRequest (HttpContext context) {
            context.Response.ContentType = "text/plain";
            context.Response.Charset = "utf-8";
            HttpPostedFile file = context.Request.Files["Filedata"];
            string uploadPath =
           HttpContext.Current.Server.MapPath(@context.Request["folder"]) + "\\";        if (file != null)
            {
                if (!Directory.Exists(uploadPath))
                {
                    Directory.CreateDirectory(uploadPath);
                }
                string time = DateTime.Now.ToString("yyyyMMddhhmmss");
                file.SaveAs(uploadPath +time+ file.FileName);
                //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
                context.Response.Write("1");
            }
            else
            {
                context.Response.Write("0");
            }  
       
            
        }
     
        public bool IsReusable {
            get {
                return false;
            }
        }}代码应该没问题,我单独做了一个demo,可以运行,没问题。这是从demo那copy过来的,调试的时候都没有运行到ashx文件
      

  11.   

    c#一窍不通,参考一下这个地址:http://blog.csdn.net/smartsmile2012/article/details/8489870
      

  12.   

    这个好像就规定了文件的类型和大小啊,我做的demo跟这个差不多,可以上传。但是我把代码搬到别的页面里的时候就传不了,主要是调试的时候都没有运行到UploadHandler.ashx
      

  13.   

    这个好像就规定了文件的类型和大小啊,我做的demo跟这个差不多,可以上传。但是我把代码搬到别的页面里的时候就传不了,主要是调试的时候都没有运行到UploadHandler.ashx哪可能是路径问题了,看一看js和UploadHandler.ashx的路径是否正确
      

  14.   

    这个好像就规定了文件的类型和大小啊,我做的demo跟这个差不多,可以上传。但是我把代码搬到别的页面里的时候就传不了,主要是调试的时候都没有运行到UploadHandler.ashx哪可能是路径问题了,看一看js和UploadHandler.ashx的路径是否正确路径应该没问题
      

  15.   

    $("#fileupload").uploadify({
             'auto':false,
             'fileObjName' : 'filedata',
             'swf': '../resources/exlib/uploadify/uploadify.swf',
             'uploader': './file',
             'fileTypeExts':'*.jpg;*.jpge;*.gif;*.png',
             'queueSizeLimit' : 1,
             //选择上传文件后调用
            'onSelect' : function(file) {
             },
             'onUploadStart' : function(file) {
             },
             'onCancel' : function(file) {
             },
             //上传到服务器,服务器返回相应信息到data里
            'onUploadSuccess':function(file, data, response){
             uploadFileSuccess(file, data, response);
             },
             'onUploadError':function(file, errorCode, errorMsg, errorString){
             uploadFileError(file, errorCode, errorMsg, errorString);
             }
         });
    感觉咱俩最大区别在于: 'fileTypeExts':'*.jpg;*.jpge;*.gif;*.png',