首页 > 代码库 > 使用ajaxfileupload.js实现上传文件功能

使用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实现上传文件功能