//获取大小
//fileid 是input:file的id
function _getFileSize(fileid) {
        try {
            var fileSize = 0;
            //for IE
            if ($.browser.msie) {
                //before making an object of ActiveXObject,
                //please make sure ActiveX is enabled in your IE browser
                var objFSO = new ActiveXObject("Scripting.FileSystemObject");
                var filePath = $("#" + fileid)[0].value;
                var objFile = objFSO.getFile(filePath);
                var fileSize = objFile.size; //size in kb
                fileSize = fileSize / 1048576; //size in mb
            }
                //for FF, Safari, Opeara and Others
            else {
                fileSize = $("#" + fileid)[0].files[0].size //size in kb
                fileSize = fileSize / 1048576; //size in mb
            }
            return fileSize;
        }
        catch (e) {
            alert("Error is :" + e);
        }
    }
    //图片预览功能
    //obj是input:file的dom对象
    function setImagePreview(obj) {
        //图片显示区,一个div
        var imgDispArea = document.getElementById("imgDispArea");
        imgDispArea.style.display = "block";
        //图片显示区内的img标签
        var imgObjPreview = document.getElementById("imgPreview");
          
        if (obj.files && obj.files[0]) {
            //火狐下,直接设img属性
            imgObjPreview.style.display = 'block';
            imgObjPreview.style.width = '300px';
            imgObjPreview.style.height = '120px';
            //imgObjPreview.src = obj.files[0].getAsDataURL();
            //火狐7以上版本不能用上面的getAsDataURL()方式获取,需要下面方式 
            imgObjPreview.src = window.URL.createObjectURL(obj.files[0]);
        } else {
            //IE下,使用滤镜
            obj.select();
            var imgSrc = document.selection.createRange().text;
              
            //必须设置初始大小
            imgDispArea.style.width = "200px";
            imgDispArea.style.height = "200px";
              
            //图片异常的捕捉,防止用户修改后缀来伪造图片
            try {
                imgDispArea.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
                imgDispArea.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
            } catch (e) {
                alert("您上传的图片格式不正确,请重新选择!");
                return false;
            }
            imgObjPreview.style.display = 'none';
            document.selection.empty();
        }
        return true;
    }