How to add cancelImg in Uploadify

别来无恙 提交于 2019-12-11 13:09:03

问题


In many of the online examples for Uploadify, you'll see a property used in the javascript plugin called "cancelImg" where you specify the little X used for the "cancel button" in the flash control, in the event that you want to cancel an upload. Doing it that way didn't work for me (no image or cancel button appears, although there is an "invisible cancel button" that you can click to cancel the upload) and the official documentation actually doesn't even specify that there exists such a property.

Does anyone know how I can get the cancel button to show up in the flash control while I'm uploading files? Using the included uploadify-cancel.png would be just fine.

Update: Here is how the flash control looks. You can see there are no cancel buttons on the right-hand side:

Here is my code:

 $(document).ready(function () {
                $("#file_upload").uploadify({
                    uploader: '@Url.Action("UploadFile", "Home")',
                    swf: '@Url.Content("~/Scripts/Uploadify/uploadify.swf")',
                    cancelImg: '@Url.Content("~/Scripts/Uploadify/uploadify-cancel.png")',
                    removeCompleted: false
                });
            });

Thanks, Jay


回答1:


Hmm...the last post doesn't really answer your question.

I had the same problem, and the solution was just to edit the file name/path for the cancel image in uploadify.css (or whatever the name of your uploadify CSS file is.) I found that the path there was incorrect so regardless of what you have after cancelImg: in your jquery code, if the filename/path is wrong in the CSS file, the cancel image (usually a cross) won't show.

Hope that's of some help.




回答2:


You can make your uploadify like this

$('#file_upload').uploadify({
        'uploader': ResourceUplodify.Uploader,
        'script': ResourceUplodify.ScriptFile,
        'cancelImg': '../../Content/images/Cancel-img.jpg',,
        'folder': ResourceUplodify.Folder,
        'fileDesc': 'Document Files',
        'formData': { 'uid': userid },
        'buttonImg': '../../Content/images/Attach-File.jpg',
        'fileExt': '*.pdf;*.doc;*.ppt;*.odt;*.rtf;*.txt',
        // 'sizeLimit': 10485760,
        'sizeLimit': sizelimit,
        'height': 29,
        'width': 90,
        'buttonText': 'Attach File',
        'multi': false,
        'auto': false,
        'onSelect': function (a, b, c, d, e) {

        },
        'onComplete': function (a, b, c, d, e) {

            }

            // }
        },
        'onError': function () {
            UploadOnError("File"); //function call
        }
    });



回答3:


Make sure that the uploadify-cancel.png file is in same directory as the uploadify.swf.

I do not use the 'cancelImg' attribute. Here's my init code:

function setUploadAttachments() {
    $("#<%=FileUpload1.ClientID %>").uploadify(
    {
        'queueSizeLimit': 1,
        'checkExisting': 'CheckForExistingFileHandler.ashx?ID=<%=this.MRID.Value %>',
        'multi': false,
        'swf': '~/../../../scripts/uploadify.swf',
        'uploader': 'UploadifyHandler.ashx',
        'fileSizeLimit': '50MB',
        'fileTypeExts': '*.gif; *.jpg; *.png; *.tif; *.xls; *.xlsx; *.csv; *.doc;',
        'auto': true,
        'method': 'post',
        'formData': { 'ID': getParameterByName("ID"), 'UID': '<%=this.UID.Value %>' },
        'onUploadComplete': function (file) {
            uploadAttachments();
        },
        'buttonText': 'Select File'
    });
}


来源:https://stackoverflow.com/questions/14404440/how-to-add-cancelimg-in-uploadify

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!