upload_b2.jsp

来自「很好的,网上商城在线购物网站系统,电子商务自助建站管理系统。适合电脑,手机,数码」· JSP 代码 · 共 71 行

JSP
71
字号
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="../../include.jsp"%> 
<html>
<head>
<base target="top">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>上传图片</title>
<%
if ( request.getMethod().equalsIgnoreCase("post") )
{
	String name = productMgr.uploadImg(request);
	out.println("<script>");
	if ( name.indexOf(".") > 0)
	{
		out.println("window.returnValue='" + name + "'");
		out.println("window.close()");

		if (session.getAttribute("progroup_upload_img")!=null)
		{
			productMgr.delProImg4Upload(session.getAttribute("progroup_upload_img").toString());
		}
		session.setAttribute("progroup_upload_img",name);
	}
	else
	{
		out.println("alert('" + name + "')");
	}
	out.println("</script>");
}
%>

<script>
function checkF(theForm)
{	
	if (theForm.file.value=="")
	{	
		alert("请选择图片");
		return(false);
	}
	return(true);
}

function prev(src)
{
	var imgObj = new Image();
	imgObj.src=src;
	document.getElementById("prev_img").innerHTML="<img width='100' height='100' src='"+src+"' id='prev_img'>";
	document.getElementById("img_size").innerHTML=imgObj.width +" x "+imgObj.height;
}
</script>
<link href="../comm.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="5">
  <form action="" method="post" enctype="multipart/form-data" name="form1" onSubmit="return checkF(this)" target="_self">
    <tr> 
      <td width="19%" height="100" align="center">预览</td>
      <td width="40%"><span id="prev_img"></span></td>
      <td width="41%" align="center" valign="middle">尺寸<br>
        <br>
        <span id="img_size"></span></td>
    </tr>
    <tr> 
      <td colspan="3"> <input name="file" type="file" onChange="prev(this.value)" size="15">
      &nbsp; <input name="Submit" type="submit" class="short-button" value=" 上 传 "> </td>
    </tr>
  </form>
</table>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?