function AutoResize(img){
foto1= new Image();
foto1.src=(img);
Controlla(img);
}
function Controlla(img){
if((foto1.width!=0)&&(foto1.height!=0)){
viewFoto(img);
} else{
funzione="Controlla('"+img+"')";
intervallo=setTimeout(funzione,20);
}
}
function viewFoto(img){
largh=foto1.width;
img_width=foto1.width;
altez=foto1.height;
img_height=foto1.height;
if(largh >= 400) {
largh = 400;
}
//if(altez >= 650) {
// altez = 450;
//}
var imgsiz
document.imgsiz.width = largh ;
document.imgsiz.alt = '원본 이미지사이즈 :' + img_width +'×'+ img_height ;
//document.imgsiz.height = altez ;
//document.photo_frm.sm.style.visibility="visible";
}
function image_onchange(){
if(document.photo_frm.upfile.value!=""){
document.photo_frm.sm.src=document.photo_frm.upfile.value;
document.photo_frm.sm.style.visibility="visible";
imgsize = document.photo_frm.upfile.value;
img_pre = 'sm';
if(event.srcElement.value.match(/(.jpg|.jpeg|.gif|.png|.JPG|.JPEG|.GIF|.PNG)/)) {
document.images[img_pre].src = event.srcElement.value;
document.images[img_pre].style.display = '';
if(document.photo_frm.sm.fileSize > 1000*1024){
document.images[img_pre].style.display = 'none';
alert("1000k 이상은 업로드 하실수 없습니다.");
}
} else {
document.images[img_pre].style.display = 'none';
if(document.photo_frm.sm.fileSize ==-1){
alert("이미지 파일만 가능합니다");
}
}
AutoResize(imgsize);
}
}
//이미지 원래크기로 팝업창 띄우기/////////////////////////////////
function AutoResize1(img){
foto1= new Image();
foto1.src=(img);
Controlla1(img);
}
function Controlla1(img){
if((foto1.width!=0)&&(foto1.height!=0)){
viewFoto1(img);
} else{
funzione="Controlla('"+img+"')";
intervallo=setTimeout(funzione,20);
}
}
function viewFoto1(img){
largh=foto1.width;
altez=foto1.height;
if(largh >= 1024 && 768 <= altez) {
largh = 1024;
}
if(largh <= 1024 && altez >= 768) {
largh = largh + 40;
altez = 768;
}
if(largh >= 1024 && altez >= 768) {
largh = 1024;
altez = 768;
}
stringa="width="+largh+",height="+altez+",left=0,top=0,scrollbars=yes";
finestra=window.open(img,"",stringa);
}
<!----- 미리 보기 ---->
<form name=photo_frm >
<table>
<tr>
<td>미리보기</td>
<td><input name="upfile" type="file" onchange="return image_onchange();">
</td>
</tr>
<tr>
<td>미리보기</td>
<td><img alt="미리보기" id="sm" src="" width="largh" style="display: none" name="imgsiz"></td>
</tr>
<tr>
<td>원본이미지 보기</td>
<td><a href="javascript:AutoResize1(document.photo_frm.upfile.value)">원본이미지 보기</a></td>
</tr>
</table>
</form>