Hidistro.UI.Common.Controls/ImageUploader/script/upimg.js

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

var frameName = "uploadFrame_" + Math.floor(Math.random() * 1000);
var postForm;
var formAction, formTarget, formMethod, formEncoding;
$(document).ready(function () {
    // 创建提交的iframe

    var isIE = (document.all) ? true : false;
    var ua = navigator.userAgent.toLowerCase();
    if (ua.indexOf("msie 9.0") > -1) {
        isIE = false;
    }

    var postFrame = isIE ? document.createElement("<iframe name=\"" + frameName + "\">") : document.createElement("iframe");
    postFrame.name = frameName;
    postFrame.style.display = "none";
    document.body.insertBefore(postFrame, document.body.childNodes[0]);
    postForm = document.forms.item(0);
    // 保存原form信息
    formAction = postForm.action;
    formTarget = postForm.target;
    formMethod = postForm.method;
    formEncoding = postForm.encoding;
});


function InitUploader(uploaderId, uploadType, snailtype, uploadSize) {
    var fileContent = document.getElementById(uploaderId + "_content");
    var fileInput = document.createElement("input");
    fileInput.name = uploaderId + "_file";
    fileInput.id = uploaderId + "_file";
    fileInput.type = "file";
    fileInput.accept = "image/*";
    fileInput.setAttribute("runat", "server");
    fileContent.appendChild(fileInput);
    fileInput.onchange = function () {
        if (!RegExp("\.(jpg|gif|png|jpeg)$", "i").test(fileInput.value)) {
            ResetUploader(uploadType, uploaderId, snailtype, uploadSize);
            alert("\u8BF7\u9009\u62E9\u4E00\u4E2A\u56FE\u7247\u6587\u4EF6");
            return;
        }
      
        postForm.target = frameName;
        postForm.method = "post";
        postForm.setAttribute("enctype", "multipart/form-data");
        postForm.encoding = "multipart/form-data";
        postForm.action = applicationPath + "/API/UpImg.ashx?action=upload&uploadType=" + uploadType + "&uploaderId=" + uploaderId + "&snailtype=" + snailtype + "&uploadSize=" + uploadSize;
        postForm.submit();

        // 还原form信息
        postForm.target = formTarget;
        postForm.method = formMethod;
        postForm.encoding = formEncoding;
        postForm.setAttribute("enctype", formEncoding);
        postForm.action = formAction;
    };
}

function ResetUploader(uploadType, uploaderId, snailtype, uploadSize) {
    var fileContent = document.getElementById(uploaderId + "_content");
    fileContent.removeChild(document.getElementById(uploaderId + "_file"));
后面还有 78 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。