使用ajaxfileupload.js实现上传文件功能

Posted justqi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用ajaxfileupload.js实现上传文件功能相关的知识,希望对你有一定的参考价值。

                    <div class="pictureList">
                        <div class="pictureItem" id="uploadItem">
                            <div class="pictureDiv">
                                <span class="commonSprite LAddWhiteBtn" onclick="triggeruploadPicture()"></span>
                                <p class="tipP">将你要上传的图片拖至此区域</p>
                                <input type="file" class="uploadPicture" onchange="uploadPicture(this)" name="Picture_path" id="Picture_path" accept="image/png,image/jpg,image/jpeg" />
                            </div>
                            <span class="uploadSpan" onclick="triggeruploadPicture()">点击上传</span>
                        </div>
                    </div>
function triggeruploadPicture() {
    $(".uploadPicture").trigger("click");
}
function uploadPicture(obj) {
    var file = $(obj).attr("id");
    $.ajaxFileUpload({
        url: ‘../../Ajax/Common/DocumentCommon.ashx?type=AddDocumentImage‘,
        //type: ‘post‘,
        timeout: 60000,
        secureuri: false,
        fileElementId: file, //file控件id
        dataType: ‘json‘,
        success: function (data, status) {
            alert(data.Msg);
            if (data.Success) {

            }
        },
        complete: function (status) { //请求完成后最终执行参数

        }
    });
}

 

以上是关于使用ajaxfileupload.js实现上传文件功能的主要内容,如果未能解决你的问题,请参考以下文章

jsp中使用jquery的ajaxfileupload插件怎么实现异步上传

ajaxfileupload.js实现无刷新异步上传图片Demo

ajaxFileUpload 实现多文件上传(源码)

ajaxFileUpload上传带参数文件及JS验证文件大小

SpringMVC结合ajaxfileupload.js实现文件无刷新上传

JFinal+ajaxfileupload实现图片的异步上传