<head>
<title>图片上传</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
<!--
window.focus();
window.οnlοad=function (){
RadioClick("file")
}
// 图片来源单选点击事件
function RadioClick(what){
if (what=="url"){ //选择远程获取
thisform.button.disabled=true;
thisform.button.value="·远程获取·";
thisform.wang1.disabled=false; //远程获取输入框可用
thisform.wang.checked=true; //远程获取Radio 点上
document.all.file.select();
document.execCommand("Delete"); //清除浏览框的数据
document.getElementById("err_msg").innerHTML=""
document.getElementById("ErrMsg").innerHTML=""
thisform.shang1.disabled=true; //使浏览框不可用
thisform.action="upfile.asp?act=ychq"
thisform.encoding="application/x-www-form-urlencoded";
FileChange();
}else{
thisform.button.disabled=true;
thisform.shang1.disabled=false;
thisform.shang.checked=true;
thisform.button.value="·开始上传·";
document.all.file1.select();
document.execCommand("Delete"); //清除浏览框的数据
document.thisform.file1.value='';
document.getElementById("err_msg").innerHTML=""
document.getElementById("ErrMsg").innerHTML=""
thisform.wang1.disabled=true;
thisform.action="upfile.asp"
thisform.encoding="multipart/form-data";
}
}
-->
</script>
<script language="JavaScript">
var AllowImgFileSize=100; //允许上传图片文件的大小 0为无限制 单位:KB
var AllowImgWidth=500; //允许上传的图片的宽度 ŀ为无限制 单位:px(像素)
var AllowImgHeight=500; //允许上传的图片的高度 ŀ为无限制 单位:px(像素)
function load(Obj){
var tempImg=new Image();
tempImg.οnerrοr=function(){ //不是图片
thisform.button.disabled=true; //提交不可用
Obj.outerHTML=Obj.outerHTML; //清除表单
document.getElementById("err_msg").innerHTML="目标类型格式不正确或者图片已损坏!"
document.getElementById("ErrMsg").innerHTML=""
};
tempImg.onreadystatechange=function(){
thisform.button.disabled=false; //提交可用
document.getElementById("err_msg").innerHTML=" 图片宽度:<font color=red>" +this.width + "</font><br> 图片高度:<font color=red>" + this.height + "</font><br> 图片大小:<font color=red>" + parseInt(this.fileSize/1024) + "K</font>";
if(AllowImgWidth!=0&&AllowImgWidth<this.width ||AllowImgHeight!=0&&AllowImgHeight<this.height ||AllowImgFileSize!=0&&AllowImgFileSize*1024<this.fileSize )
{
document.all.file1.select();
document.execCommand("Delete");
Obj.outerHTML=Obj.outerHTML;
document.getElementById("ErrMsg").innerHTML="/n图片不要超过<font color=red>"+AllowImgFileSize+"</font>KB。<font color=red>"+AllowImgWidth+"</font>X<font color=red>"+AllowImgHeight+"</font>"
thisform.button.disabled=true;
}
else{
document.getElementById("ErrMsg").innerHTML=""
document.all.err_msg.style.display='';
}
};
tempImg.src=Obj.value;
}
function up(){
if(thisform.button.disabled) event.returnValue=false;
}
</script>
<script language="JavaScript">
var flag=false;
function DrawImage(ImgD){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= 120/80){
if(image.width>120){
ImgD.width=120;
ImgD.height=(image.height*120)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
else{
if(image.height>80){
ImgD.height=80;
ImgD.width=(image.width*80)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}
function FileChange(Value){
flag=false;
document.all.uploadimage.width=0;
document.all.uploadimage.height=0;
document.all.uploadimage.alt="";
document.all.uploadimage.src=Value;
}
function mysub()
{
esave.style.visibility="visible";
}
</script>
<style>
<!--
body { font-size: 2; font-family: monospace }
-->
</style>
</head>
<body topmargin="0"style="border:0px;" scroll="no">
<form name="thisform" method="post" οnsubmit="javascript:up();">
<div id="esave" style="position:absolute; top:18px; left:40px; z-index:10; visibility:hidden">
<table width="340" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20%"></td>
<td bgcolor="#104A7B" width="60%">
<table width="100%" height="120" border="0" cellspacing="1" cellpadding="0">
<tr>
<td bgcolor="#eeeeee" align="center"><marquee align="middle" behavior="alternate" scrollamount="5"><font color="#FF0000">...图片上传中...请等待...</font></marquee></td>
</tr>
</table>
</td>
<td width="20%"></td>
</tr>
</table>
</div>
<table width="400" border="0" cellspacing="0" cellpadding="3" align="center">
<tr>
<td height="22" align="center" width="400">
<fieldset style="width: 384; height: 60">
<legend><font color="#FF0000">图片来源</font></legend>
<table border="0" cellpadding="0" cellspacing="0" width="380">
<tr>
<td οnclick="RadioClick('file')">
<input type="radio" id="shang" value="sc" name="lb" οnclick="RadioClick('file')">本地上传: </td>
<td>
<input type="file" id="shang1" name="file" style="width:280'"contentEditable=false class="an3" value size="20" disabled onpropertychange="javascript:load(this);" οnchange="javascript:FileChange(this.value);">
</td>
</tr>
<tr>
<td οnclick="RadioClick('url')">
<input type="radio" id="wang" value="wl" name="lb" οnclick="RadioClick('url')">远程获取:</td>
<td><input type="text" name="file1" id="wang1" style="width:280px" size="20" disabled class="an3" onpropertychange="javascript:load(this);"></td>
</tr>
</table>
</fieldset></td>
</tr>
<tr align="center" valign="middle">
<td height="80" width="400">
<fieldset style=" height: 80">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width=150 align="center"><img id="uploadimage" height="0" width="0" src οnlοad="javascript:DrawImage(this);"></td>
<td width=250 align="left">
<div id="err_msg" ></div>
<div id="ErrMsg" ></div>
</td>
</tr>
</table>
</fieldset>
</td>
</tr>
<tr align="center" valign="middle">
<td height="24" width="400">
<input type="submit" name="button" value disabled class="an1" οnclick="javascript:mysub()">
</td>
</tr>
</table>
</form>
</body>