📄 save.jsp
字号:
<%@ page import="java.io.*" %>
<%@ include file="base64.jsp" %>
<%
/*--------------------------------------------------------------------
This script accepts the image from the posted parameter 'image'.
The image data are BASE64 encoded so the script has to decodes it
to binary byte array. Then itsaves it to a disk file.
Then the script asks the applet to redirect the browser to the 'view.htm'
to prove that the image is saved successfully. For that it outputs
the command:
#SHOWDOCUMENT=view.htm
---------------------------------------------------------------------*/
// get the submitted image data
String image = request.getParameter("image");
if (image != null) {
// get image bytes
byte imageBytes[] = Base64Decode(image);
// This script saves the image to the script's directory as 'image.png',
// but you can use any desirable file name and destination directory.
File saveDir =
new File(application.getRealPath(request.getServletPath())).getParentFile();
String filename = "image.png";
OutputStream os = new FileOutputStream(new File(saveDir,filename));
os.write(imageBytes);
os.close();
// Redirect the browser to the 'view.html' to display the saved image
out.println("#SHOWDOCUMENT=view.htm");
}
else
out.println("#SHOWSTATUS=Image is not found in the request");
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -