close
<input type="file" name="FileUpload1" id="FileUpload1" class="form-control" style="width:400px;" runat="server" />
<img id="testImg" src="#" alt="your image" />
                <script>
                    $(function () {
                        $('#testImg').hide();
                    });
                    function getImgSize(input) {
                        if (input.files && input.files[0]) {
                            var reader = new FileReader();
                            reader.onload = function (e) {
                                $('#testImg').attr('src', e.target.result);
                            }
                            reader.readAsDataURL(input.files[0]);
                        }
                    }

                    $('#testImg').on('load', function () {
                        if (($(this).width() == 77) && ($(this).height() == 50)) {
                        } else {
                            $('#<%=FileUpload1.ClientID%>').val('');
                            alert('※上傳檔案尺寸不符規定※');                                    
                            }
                        })
                        $('#<%=FileUpload1.ClientID%>').change(function () {
                        getImgSize(this);
                    });
                        </script>
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 amychang2014 的頭像
    amychang2014

    工作需要筆記

    amychang2014 發表在 痞客邦 留言(0) 人氣()