makeupload.java

来自「JAVA邮件系统」· Java 代码 · 共 69 行

JAVA
69
字号
import java.io.*;
import java.text.*;
import java.util.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class MakeUpload extends HttpServlet 
{

    public void doPost(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException
    {
		doGet(request,response);
	}
	
	public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException
    {
		HtmlOut htmlOut = new HtmlOut (response);
		
		// 得到名字和口令
		String name = CommonMethods.getParameterValue (request,"Name");
		String pass = CommonMethods.getParameterValue (request,"Password");
		if(name!=null&&pass!=null){
			htmlOut.addCookie ("username",name);
			htmlOut.addCookie ("password",pass);
		}
		else{//other we get it by cookie;
			name = CommonMethods.GetUserName(request);
			pass = CommonMethods.GetUserPass(request);
		}
		Person p=new Person();
		p.setName (name);
		if( p.getName ()==null || (!p.checkPassword(pass))
			||(!p.IsSuperMan ()&&!p.IsManager ()) )
		{
	    	htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"",
								"请先登录!","/manage/");
			htmlOut.outHtml();
			return;
		}
		
		String sFile=CommonMethods.getParameterValue (request,"filename");
		String sD=CommonMethods.getParameterValue (request,"dir");
		String sInfo=CommonMethods.getParameterValue (request,"info");
		
		String sDir=CommonMethods.sHtmlPath;
		
		if( sFile==null || sInfo==null ){
			htmlOut.addString ("数据不全!");
			htmlOut.outHtml();
			return;
		}
		if( sD==null)
			sD="";
		if( sD.indexOf(':')==-1 )
			sDir += sD;
		else
			sDir = sD;
		sDir += sFile;
		CommonMethods.WriteToDisk (sInfo.getBytes (),sDir);
		htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"","已成功上载文件","/WebMange");
		htmlOut.outHtml();
	}
}
	

⌨️ 快捷键说明

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