blueimp文件上传插件IE问题

时间:2011-09-11 14:24:31

标签: jquery asp.net-mvc-3 file-upload

我使用blue-imp jquery.fileupload basic plug int在网站上构建我自己的多文件上传UI。 Internet Explorer存在问题。 我没有在fileupload插件中触发Done事件。

代码是:

function setFotoUpload() {
        $('#fotoUploadContainer').fileupload({
                dataType:"json",
                url:"/ilan/resimkaydet",
                add:function(e,data) {
                    if(data.files.length + $('#fotoContainer .satir').length > 10 ) {
                        if(!data.uyarildi)
                            {
                                data.uyarildi = true;
                                alert("10 resime kadar ekleyebilirsiniz.");
                                return ;
                            }
                    }
                    $.each(data.files, function(index, file) {
                        data.satir = $('<div class="satir"><span class="imgW"><img src="/Content/style/image/loading.gif" /></span><span class="isimW">' + file.name.replace('"','').replace('','') + '</span><span class="tamamlanan"></span></div>').appendTo($('#fotoContainer'));
                    });
                    data.submit();
                },
                send:function(e,data) {
                },
                progress:function(e, data) {
                    data.satir.find('.tamamlanan').html('Yükleniyor : '+ parseInt(data.loaded / data.total * 100, 10)+' %');
                },
                done:function(e,data) {

                    data.satir.append('<span class="sil ico-button">Sil</span>');
                    data.satir.append('<span class="vitrinFotoYap ico-button">Vitrin Fotoğrafı Yap</span>');
                    data.satir.append('<span class="yukariTasi ico-button">▲</span>');
                    data.satir.append('<span class="asagiTasi ico-button">▼</span>');

                    data.satir.find('img').attr('src',data.result.Name);
                    data.satir.find('.tamamlanan').remove();
                }

            }
        );

        $('#fotoContainer .satir .sil').live('click', function () {
        $(this).parent('.satir').remove();
    });

我的Html代码就像

<div id="fotolar">
        <span id="val-error61" class="val-error" style="display: none;">Lütfen vitrin fotoğrafınızı
            belirleyiniz.</span>
        <img class="fotoLogo" src="/Content/style/image/ilan/ekle/ilanDetay/fb.png" />
        <div class="fotoIslem">
                <span class="ico-button btnResimEkle" style="position:relative;">
            <form id="fotoUploadContainer" action="/ilan/resimkaydet"  class="ico-button" method="POST" enctype="multipart/form-data">
                    <input type="file" id="fotoUploader" name="inputFile" multiple="true" style="position: absolute;
                        top: 0;
                        right: 0;
                        border: solid transparent;
                        opacity: 0;
                        filter: alpha(opacity=0);
                        -o-transform: translate(250px,-50px) scale(1);
                        -moz-transform: translate(-300px,0) scale(4);
                        direction: ltr;
                        cursor: pointer;
                        margin: 0;
                        border-width: 0 0 100px 200px;" />
                </form>Resim Ekle</span>
            <span class="ico-button btnHepsiniSil">Hepsini Sil</span>

            </div>
        <div id="fotoContainer">
            @if (Model.tIlanResim != null)
            {
                foreach (var item in Model.tIlanResim)
                {
                <div class="satir">
                    <span class="imgW">s
                        <img src="@(item.Yol.Replace("Foto/", "Foto/th"))" /></span><span class="isimW">İlan
                            Resmi</span><span class="sil ico-button">Sil</span><span class="vitrinFotoYap ico-button">Vitrin
                                Fotoğrafı Yap</span><span class="yukariTasi ico-button">▲</span><span class="asagiTasi ico-button">▼</span></div>
                }
            }
        </div>
    </div>

Mvc3行动是:

[KayitliKullanici, HttpPost]
    public ActionResult ResimKaydet(HttpPostedFileBase inputFile)
    {
        string str = DateTime.Now.ToFileTime().ToString();

        string extension = Path.GetExtension(inputFile.FileName);
        if ((extension != ".jpg" && extension != ".jpeg") && ((extension != ".png" && extension != ".gif") && extension != ".bmp"))
        {
            return null;
        }
        var saveName = str + extension;

        string path = GlobalPaths.TempFolder + saveName;
        var fileName = Server.MapPath(path);
        inputFile.SaveAs(fileName);
        new IlanIslem().ResimKaydet(Server.MapPath(path), Server.MapPath(GlobalPaths.TempFolder));

        return Json(new
        {
            inputFileName = inputFile.FileName,
            Name = GlobalPaths.TempFolder + "th" + saveName,
            Length = inputFile.ContentLength,
            Type = inputFile.ContentType
        });


        return new EmptyResult();
        //return new ContentResult { Content = GlobalPaths.TempFolder + "pre" + str + extension };
    }

我用谷歌搜索但找不到答案。

1 个答案:

答案 0 :(得分:1)

根据this example here,您应该将Content-Type响应标头设置为“text / plain”,并且事件应该开始触发。