⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 image.jsp

📁 A brew application taking backup of the device
💻 JSP
字号:
<%@page import="java.io.*, javax.servlet.http.HttpServletRequest, javax.servlet.ServletInputStream" %><%@page import="java.io.File, java.io.IOException" %><?xml version="1.0" encoding="ISO-8859-1"?><root>    <data>    <%	   String filename = "", contentType = "", fileData = "", strLocalFileName = "";	   int startPos = 0, endPos = 0, BOF = 0, EOF = 0;    %>    <%!	void copyByte(byte [] fromBytes, byte [] toBytes, int start, int len)	{		for(int i=start;i<(start+len);i++)		{			toBytes[i - start] = fromBytes[ i ];		}	}    %>    <%    contentType = request.getContentType();    out.print(contentType);	if ((contentType != null))   //&& (contentType.indexOf("multipart/form-data") >= 0))    {		DataInputStream in = new DataInputStream(request.getInputStream());		DataInputStream in1 = in;		int formDataLength = request.getContentLength();        out.print(formDataLength);		byte dataBytes[] = new byte[formDataLength];		int byteRead = 0, totalBytesRead = 0;		while (totalBytesRead < formDataLength)		{			byteRead = in1.read(dataBytes, totalBytesRead, formDataLength);			totalBytesRead += byteRead;		}		byte[] line = new byte[128];		String boundary = "", s = "";		int count = 0, pos = 0;		do		{			copyByte(dataBytes, line, count ,1);			count+=1;			s = new String(line, 0, 1);			fileData = fileData + s;			pos = fileData.indexOf("Content-Disposition: form-data; name=\"");			if(pos != -1)				endPos = pos;		}while(pos == -1);		boundary = fileData.substring(startPos, endPos);		startPos = endPos;		do		{			copyByte(dataBytes, line, count ,1);			count+=1;			s = new String(line, 0, 1);			fileData = fileData + s;			pos = fileData.indexOf("filename=\"", startPos);			if(pos != -1)				startPos = pos;		}while(pos == -1);		do		{			copyByte(dataBytes, line, count ,1);			count+=1;			s = new String(line, 0, 1);			fileData = fileData + s;			pos = fileData.indexOf("Content-Type: ", startPos);			if(pos != -1)				endPos = pos;		}while(pos == -1);		filename = fileData.substring(startPos + 10, endPos - 3);		strLocalFileName = filename;        out.println(strLocalFileName);		int index = filename.lastIndexOf("\\");        out.println(index);		if(index != -1) {			filename = filename.substring(index + 1);            out.println(filename);        }		else			filename = filename;		boolean blnNewlnFlag = false;		startPos = endPos;		do		{			copyByte(dataBytes, line, count ,1);			count+=1;			s = new String(line, 0, 1);			fileData = fileData + s;			pos = fileData.indexOf("\n", startPos);			if(pos != -1)			{				if(blnNewlnFlag == true)					endPos = pos;				else				{					blnNewlnFlag = true;					pos = -1;				}			}		}while(pos == -1);		contentType = fileData.substring(startPos + 14, endPos);        out.println(contentType);		BOF = count + 1;		do		{			copyByte(dataBytes, line, count, 1);			count+=1;			s = new String(line, 0, 1);			fileData = fileData + s;			pos = fileData.indexOf(boundary, startPos);		}while(pos == -1);		EOF = count - boundary.length();        out.println("Local File Name = " + strLocalFileName);		out.println("filename = " + filename);		out.println("contentType = " + contentType);		String destFolder = "E:\\MOBILE_DATA\\FILE_UPLOAD\\";        out.println(destFolder);		filename= destFolder + filename;		FileOutputStream fileOut = new FileOutputStream(filename);		fileOut.write(dataBytes, BOF, (EOF-BOF));		fileOut.flush();		fileOut.close();        out.print("success");        out.println("File saved as >> " + filename);	}	else	{		out.println("Error in uploading ");	}   %>    </data></root>

⌨️ 快捷键说明

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