<%@ page contentType="text/html;charset=GBK" %>

<%@ page import="com.jivesoftware.util.RandomStrg,com.jdon.picture.*,com.jivesoftware.forum.JiveGlobals" %>

<html>
<head>
    <title>upload File</title>
    <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <link rel="stylesheet" href="jivejdon.css" type="text/css">
</head>
<SCRIPT language = "Javascript">
<!--
function selectpic(fileurl,filename){
	if ((fileurl.toLowerCase().indexOf("c:") > -1) ||
	    (fileurl.toLowerCase().indexOf("d:") > -1) ||
		(fileurl.toLowerCase().indexOf("e:") > -1) ||
		(fileurl.toLowerCase().indexOf("f:") > -1))
	{
        alert("你硬盘上的文件必须上传！");
         return false;
	}

  if(window.opener.document.postForm.body!=null){
             filetext="[url="+fileurl+"]"+filename+"[/url]";
             window.opener.document.postForm.body.value += filetext;
             window.close();

    }
}
//-->
</script>
<body>

<%
String status="";
if (request.getParameter("status")!=null)
   status=request.getParameter("status");


if (status.equals("save")){
    String icon=request.getParameter(request.getParameter("picname"));
    String uploadurl=JiveGlobals.getJiveProperty("upload.relurl");

%>
<center><a href="<%=uploadurl+icon%>" target=_blank><%=uploadurl+icon%></a>
<br>
上传成功。
 <form>
<input type="button" value="确定" onclick="selectpic('<%=uploadurl+icon%>','<%=icon%>')" >
</form>
 </center>
</center>

<%
return;
}

  if (request.getParameter("pic")==null)
    return;
  RandomStrg rstr=new RandomStrg();
  rstr.setCharset("a-zA-Z0-9");
  rstr.setLength(10);
  rstr.generateRandomObject();
  String picname=request.getParameter("pic")+rstr.getRandom();
%>

<script>
<!--

function validate(){
    var field=document.form1.<%=picname%>;
	if (field.value.toLowerCase().indexOf("http://") > -1){
        alert("你必须提供你硬盘上的文件上传");

         return false;

	}
    return true;
}

-->
</script>


<form name="form1" action="<%=request.getContextPath()%>/multipartformserv" method="post" enctype="multipart/form-data" onSubmit="return validate()">
<input type="hidden" name="<%=MultipartFormHandle.FORWARDNAME%>" value="uploadfile.jsp">
<table align="center">
<tr ><td colspan=2>上传文件大小 < <%=MultipartFormHandle.SIZE%>K </td></tr>
<tr><td>文件: </td><td><input type=file name='<%=picname%>' size=30  class=form ><br></td></tr>

 <tr><td></td><td>
<input type="hidden" name="picname" value="<%=picname%>">
<input type=submit value="上传" class=Button ><br>
<input type="hidden" name="status" value="save">
 </td></tr>
</table>
</form>



