PHP 8.1.33
Preview: imageCapture.jsp Size: 1.08 KB
/home/jambtst2015/www/ckeditor/capture/imageCapture.jsp

<%@ page import="java.io.*"%><%
	String image = request.getParameter("image");
	
	// size protection 
	if(image==null || image.length()>100000) return;
	
	byte[] bytes = org.apache.commons.codec.binary.Base64.decodeBase64(image);
	if(bytes==null) return;
		
	String save = request.getParameter("save");
	String name = request.getParameter("name");
	String type = request.getParameter("type");
	if(save!=null && name!=null && ("JPG".equalsIgnoreCase(type) || "PNG".equalsIgnoreCase(type) )){
		String webappRoot = getServletContext().getRealPath("/");
		File folder = new File(webappRoot + "/capture/img/");
		File fileName = new File(folder, name + "." + type);
		FileOutputStream fos = new FileOutputStream(fileName);
		fos.write(bytes);
		fos.close();
		/*
		 the path can be:
		 	http://your_server/.../img/..
		 or
		 	/capture/img/...
		 or relative
		 	img/...
		*/
		
		%>img/<%=name%>.<%=type%><%
	}else{
		response.setContentType("image/jpeg");
		OutputStream os = response.getOutputStream();
		for(int i=0; i<bytes.length; i++){
			os.write(bytes[i]);
		}
		os.flush();
		os.close();
	}
		
%>

Directory Contents

Dirs: 1 × Files: 3

Name Size Perms Modified Actions
img DIR
- drwxrwxrwx 2024-11-22 17:53:01
Edit Download
4.85 KB lrw-r--r-- 2025-11-03 10:00:52
Edit Download
1.08 KB lrw-r--r-- 2024-11-22 17:53:01
Edit Download
455 B lrw-r--r-- 2024-11-22 17:53:01
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).