Html & Script

초간단 업로드전 이미지 용량 파일검사하기-ㅋ

페이지 정보

본문

/* nuno21.net  수정 */

 

<script> 

function chkImgFile(fld_id) { 

    var fld = document.getElementById(fld_id);

    var fname = fld.value; 

    if((/(.jpg|.jpeg|.gif|.png)$/i).test(fname)) {

        fld.src = fname; 

    } else  {

        if(fld.value) alert('이미지는 gif, jpg, png 파일만 가능합니다.'); 

        fld.value = '';

    }

 

    if(fld.files[0].size>512000) {alert('500Kb 이하로 등록해주세요'); fld.value = '';}

 

}

</script>

 

 

-------------------------------------------------------------------------

 

....

<img width="200" height="150" align="absbottom" border="0" src="기본이미지.jpg" onload="if(this.fileSize>300000)alert('300kbyte 넘는데요^^')" ;="">

<input type="file" onchange="CkImageVal()" name="file1">

....

 

덤으로 하나 더...ㅋㅋ..........................................

 

자바스크립이용 이미지에서 추출할수 있는 정보들입니다.

 

<img src="http://www.qaboard.co.kr/img/qaboard.gif" name="test">

<script>

var obj=document.test;

var objName="하드이미지";

for(var i in obj){

document.write(objName+"."+i+"="+obj[i]+"<br>");

}

</script>

 

실행결과:

하드이미지.language=

하드이미지.scrollHeight=35

하드이미지.isTextEdit=false

하드이미지.currentStyle=[object]

하드이미지.document=[object]

하드이미지.onmouseup=null

하드이미지.oncontextmenu=null

하드이미지.isMultiLine=true

하드이미지.clientHeight=35

하드이미지.onrowexit=null

하드이미지.onbeforepaste=null

하드이미지.onactivate=null

하드이미지.scrollLeft=0

하드이미지.lang=

하드이미지.onmousemove=null

하드이미지.onmove=null

하드이미지.onselectstart=null

하드이미지.parentTextEdit=[object]

하드이미지.oncontrolselect=null

하드이미지.canHaveHTML=false

하드이미지.onkeypress=null

하드이미지.oncut=null

하드이미지.onrowenter=null

하드이미지.onmousedown=null

하드이미지.onpaste=null

하드이미지.className=

하드이미지.id=

하드이미지.onreadystatechange=null

하드이미지.onbeforedeactivate=null

하드이미지.hideFocus=false

하드이미지.dir=

하드이미지.isContentEditable=false

하드이미지.onkeydown=null

하드이미지.clientWidth=400

하드이미지.onlosecapture=null

하드이미지.parentElement=[object]

하드이미지.ondrag=null

하드이미지.ondragstart=null

하드이미지.oncellchange=null

하드이미지.recordNumber=null

하드이미지.onfilterchange=null

하드이미지.onrowsinserted=null

하드이미지.ondatasetcomplete=null

하드이미지.onmousewheel=null

하드이미지.ondragenter=null

하드이미지.onblur=null

하드이미지.onresizeend=null

하드이미지.onerrorupdate=null

하드이미지.onbeforecopy=null

하드이미지.ondblclick=null

하드이미지.scopeName=HTML

하드이미지.onkeyup=null

하드이미지.onresizestart=null

하드이미지.onmouseover=null

하드이미지.onmouseleave=null

하드이미지.outerText=

하드이미지.innerText=

하드이미지.onmoveend=null

하드이미지.tagName=IMG

하드이미지.title=

하드이미지.offsetWidth=400

하드이미지.onresize=null

하드이미지.contentEditable=inherit

하드이미지.runtimeStyle=[object]

하드이미지.filters=[object]

하드이미지.ondrop=null

하드이미지.onpage=null

하드이미지.onrowsdelete=null

하드이미지.tagUrn=

하드이미지.offsetLeft=10

하드이미지.clientTop=0

하드이미지.style=[object]

하드이미지.onfocusout=null

하드이미지.clientLeft=0

하드이미지.ondatasetchanged=null

하드이미지.canHaveChildren=false

하드이미지.ondeactivate=null

하드이미지.isDisabled=false

하드이미지.onpropertychange=null

하드이미지.ondragover=null

하드이미지.onhelp=null

하드이미지.ondragend=null

하드이미지.onbeforeeditfocus=null

하드이미지.disabled=false

하드이미지.onfocus=null

하드이미지.behaviorUrns=[object]

하드이미지.accessKey=

하드이미지.onscroll=null

하드이미지.onbeforeactivate=null

하드이미지.onbeforecut=null

하드이미지.readyState=uninitialized

하드이미지.all=[object]

하드이미지.sourceIndex=4

하드이미지.onclick=null

하드이미지.scrollTop=0

하드이미지.oncopy=null

하드이미지.onfocusin=null

하드이미지.tabIndex=0

하드이미지.onbeforeupdate=null

하드이미지.outerHTML=

하드이미지.innerHTML=

하드이미지.ondataavailable=null

하드이미지.offsetHeight=35

하드이미지.onmovestart=null

하드이미지.onmouseout=null

하드이미지.scrollWidth=400

하드이미지.offsetTop=15

하드이미지.onmouseenter=null

하드이미지.onlayoutcomplete=null

하드이미지.offsetParent=[object]

하드이미지.onafterupdate=null

하드이미지.ondragleave=null

하드이미지.children=[object]

하드이미지.start=fileopen

하드이미지.firstChild=null

하드이미지.href=http://www.qaboard.co.kr/img/qaboard.gif

하드이미지.height=35

하드이미지.alt=

하드이미지.isMap=false

하드이미지.fileModifiedDate=

하드이미지.fileUpdatedDate=07/23/2003

하드이미지.dataSrc=

하드이미지.onerror=null

하드이미지.hspace=0

하드이미지.previousSibling=null

하드이미지.loop=1

하드이미지.protocol=HTTP(HyperText Transfer Protocol)

하드이미지.lastChild=null

하드이미지.nodeName=IMG

하드이미지.nodeType=1

하드이미지.dynsrc=

하드이미지.attributes=[object]

하드이미지.childNodes=[object]

하드이미지.src=http://www.qaboard.co.kr/img/qaboard.gif

하드이미지.dataFld=

하드이미지.ownerDocument=[object]

하드이미지.parentNode=[object]

하드이미지.onabort=null

하드이미지.fileSize=-1

하드이미지.dataFormatAs=

하드이미지.width=400

하드이미지.vrml=

하드이미지.onload=null

하드이미지.align=

하드이미지.useMap=

하드이미지.lowsrc=

하드이미지.fileCreatedDate=

하드이미지.complete=false

하드이미지.nextSibling=[object]

하드이미지.vspace=0

하드이미지.mimeType=

하드이미지.nodeValue=null

하드이미지.nameProp=qaboard.gif

하드이미지.border=

하드이미지.longDesc=

하드이미지.name=test

관련자료

nuno님의 댓글

var file0 = document.getElementById('bf_file0');
        var del0  = document.getElementById('bf_file_del0');
        if (file0.value == '') {
            if (f.w.value == '' || (f.w.value == 'u' && del0 && del0.checked)) {
                alert('첫번째 파일은 이미지 파일로 등록해 주십시오.');
                file0.select();
                return false;
            }
        } else {
            var pattern = /\.(gif|jpe?g|png)$/i;
            if (!pattern.test(file0.value)) {
                alert('첫번째 파일은 이미지 파일로 등록해 주십시오..');
                file0.select();
                return false;
            }
        }
Today's proverb
삶을 깊이 이해하면 할수록 죽음에 대한 슬픔은 그만큼 줄어든다. (톨스토이)