📄 insertimg.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" session="true"
import = "java.util.*,java.text.*,java.text.DecimalFormat,java.math.*,com.jspsmart.upload.*, com.jl.rp.*"
%>
<%
request.setCharacterEncoding("ISO8859-1");
boundWithSession bound = (boundWithSession)session.getAttribute("bound");
if(bound == null){
bound = new boundWithSession();
session.setAttribute("bound", bound);
}
String whichType = (String)session.getAttribute("whichType");
queryParent qp = new queryParent();
qp.doQuey(whichType);
StringBuffer strBuf = new StringBuffer();
ArrayList al = qp.arrayList;
for(int i=0;al!=null && i<al.size();i++){
strBuf.append("folder"+al.get(al.size()-i-1)+"\\");
}
out.println(whichType);
java.io.File fileNew = new java.io.File(rpPathconf.newsUpPath+strBuf.toString());
if(!fileNew.exists())
fileNew.mkdirs();
Vector vec = (Vector)bound.getImageCollection();
Vector insertVec = (Vector)bound.getInsertCollection();
SmartUpload su = new SmartUpload();
su.initialize(pageContext);
String attachPath="";
try {
if("upload".equals(su.getRequest().getParameter("action"))){
su.upload();
if(su.getFiles().getCount() > 0) {
for(int i=0;i<su.getFiles().getCount();i++){
com.jspsmart.upload.File file = su.getFiles().getFile(i);
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
format.setLenient(false);
String strResponseDate = format.format(date);
attachPath = strResponseDate+"."+file.getFileExt();
file.saveAs(rpPathconf.newsUpPath+strBuf.toString()+attachPath);
vec.add(strBuf.toString()+attachPath);
insertVec.add(strBuf.toString()+attachPath);
}
}
}
} catch(Exception e) {
//e.printStackTrace();
}
%>
<html>
<head>
<title>图片插入</title>
<style type="text/css">
<!--
body {
font-family: "Verdana", "宋体";
font-size: 9pt;
border: none;
}
input {
font-family: "Verdana", "宋体";
font-size: 9pt;
}
-->
</style>
<script Language="JavaScript">
function upload(){
var boFlag = true;
if(form1.file.value == ""){
boFlag = false;
alert("请首先选择项目进行上传!");
return;
}
if(boFlag){
form1.action.value="upload";
form1.submit();
}
}
function deleteFile(){
form1.action.value="delete";
form1.submit();
}
function doPageLoad() {
window.focus();
}
function check(obj) {
form1.uploadBtn.disabled = "" ;
}
function doChange(obj) {
form1.uploadBtn.disabled = true ;
document.picView.src='file://'+obj.value;
}
function submitCurrent() {
window.parent.txtFileName.value =form1.elements("filePath").value ;<!-- form1.elements("filePath").value -->
form1.uploadBtn.disabled = true ;
}
</script>
</head>
<body leftmargin="0" topmargin="0" onload="doPageLoad()">
<div style="height: 22px; padding-left: 30px; padding-top: 5px; color: #DADADA; filter: progid:DXImageTransform.Microsoft.gradient(GradientType=1, startColorstr=#003366, endColorstr=#FFFFFF)">附件上传</div><br />
<form name="form1" method="post" action="insertImg.jsp" ENCTYPE="multipart/form-data">
<center>
<div style="width: 90%;">
<fieldset>
<legend>选择图片</legend>
<p align="left" style="padding-left: 20px;">文件:
<img name="picView" src="<%=strBuf.toString()+attachPath%>" onload="check(this)" width="180" alt="图片预览" style="vertical-align: text-bottom;" border="1">
<br />
<input type="filename" name="file" value="" onChange="doChange(this)">
<input type="hidden" name="filePath" value="<%="http://localhost:8080/newedition/rp/getAttachTemp.jsp?path="+strBuf.toString()+attachPath%>" >
</p>
<p align="left" style="padding-left: 20px; padding-bottom: 18px;">
<input type="button" name="uploadBtn" value=" 上传 " onclick="return upload()">
<input type="hidden" name="action" value="">
</p>
</fieldset>
</div>
</center>
</form>
</body>
</html>
<script language=Javascript>
submitCurrent();
</script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -