Web/Javascript

자바스크립트에서 업로드전 용량 검사하기

aucd29 2013. 9. 26. 21:33
악플반사~~반사
업로드전 검사하는 방법 무지 복잡해서 이미지는 간단 체크가 가능해서 올렸습니다.
여기 없는거 같아소..ㅋㅋ ^----^V 므흐...

<img src="url" onLoad="if(this.fileSize>300000)alert('300kbyte 넘는데요^^')";>


이거만 있음 부족한데 깜박했네요..;;; 업데이트..ㅋㅋ
이를 응용해서
이미지 파일선택하면 미리보기 기능과 파일확장자 걸러내는 자바스크립입니다. 그럼..이만
<script>
function CkImageVal() {
var oInput = event.srcElement;
var fname = oInput.value;
if((/(.jpg|.jpeg|.gif|.png)$/i).test(fname))
oInput.parentElement.children[0].src = fname;
else
alert('이미지는 gif, jpg, png 파일만 가능합니다.');
}</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