Óà JSP ×Ô¼º±àд CKEditor ͼƬÉÏ´«·þÎñÆ÷¶Ë´úÂë
½ñÌìѧ»áÁËÈçºÎ×Ô¼º±àд JSP ÓÃÀ´´¦Àí CKEditor µÄͼƬÉÏ´«¡£
<%@ page import="org.apache.commons.fileupload.FileItem" %>
<%@ page import="java.util.List" %>
<%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory" %>
<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload" %>
<%@ page import="org.apache.commons.io.FilenameUtils" %>
<%@ page import="java.io.File" %>
<%@ page import="org.apache.commons.lang.StringUtils" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
String callback = request.getParameter("CKEditorFuncNum");
try {
if (ServletFileUpload.isMultipartContent(request)) {
ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());
List<FileItem> fileItemsList = servletFileUpload.parseRequest(request);
String filename = String.valueOf(System.currentTimeMillis());
for (FileItem item : fileItemsList) {
if (!item.isFormField()) {
String _filename = item.getName();
filename += "." + FilenameUtils.getExtension(_filename);
String clientPath = "images/" + filename; // ÕâÀïÓ¦¸ù¾ÝÐèÒªÐ޸ġ£
File file = new File(application.getRealPath(clientPath));
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
item.write(file);
}
}
%>
<mce:script type="text/javascript"><!--
window.parent.CKEDITOR.tools.callFunction(<%=callback%>, '<%=clientPath%>', '');
// --></mce:script>
<%
}
} catch (Excepti
Ïà¹ØÎĵµ£º
ÔںܶàÓ¦ÓÃ϶¼¿ÉÄÜÓÐÐèÒª½«Óû§µÄÕæʵIP¼Ç¼ÏÂÀ´£¬Õâʱ¾ÍÒª»ñµÃÓû§µÄÕæʵIPµØÖ·£¬ÔÚJSPÀ»ñÈ¡¿Í»§¶ËµÄIPµØÖ·µÄ·½·¨ÊÇ£º request.getRemoteAddr()£¬ÕâÖÖ·½·¨Ôڴ󲿷ÖÇé¿ö϶¼ÊÇÓÐЧµÄ¡£µ«ÊÇÔÚͨ¹ýÁËApache,SquidµÈ·´Ïò´úÀíÈí¼þ¾Í²»ÄÜ»ñÈ¡µ½¿Í»§¶ËµÄÕæʵIPµØÖ·ÁË¡£
¡¡¡¡Õâ¶Îʱ¼äÔÚ×öIPͳ¼ÆµÄ³ÌÐòÉè¼Æ£¬ÓÉÓÚ·þÎñÆ÷×÷ÁË ......
ÒÔÏÂΪÔÚjspÒ³ÃæjavascriptʵÏÖ·½Ê½£º
Èç¹ûÐèÒªÉèÖõØÖ·¹©Óû§ÏÂÔØʹÓÃ
1. ÐèÒªµ¼ÈëjspSmartUpload.jar°ü¡£
2. ÔÚÒ³ÃæÌí¼Ó<%@ page import=”com..jspsmart.upload.*”%>
function createOCX()
{
try
{
//´´½¨ActiveXobject¶ÔÏóʱ´«Èë²å¼þµÄVersionIndependProgID
//´Ë´¦ÅжÏϵͳÖÐÊÇ·ñ°²×°meid ......
¹ØÓÚһЩFCFµÄ»ù´¡¸ÅÄî¿ÉÒÔÔÚgoogleÉÏÃæËÑË÷“FusionChartsFree ÖÐÎÄ¿ª·¢Ö¸ÄÏ”¡££¨×¢Ò⣬Õâ¸ö×ÊÁÏÀïÃæ¶ÔÓÚÖÐÎÄÂÒÂëµÄÎÊÌⲢûÓÐ×ö³ö½â¾ö£¬½â¾ö·½·¨²Î¿¼£ºhttp://yongboy.javaeye.com/blog/270092£©
ÔÚÁ˽âÁËһЩ±ØÒªµÄ¸ÅÄîºó£¬²ÅÊDZ¾ÎĵÄÖص㣬×öÒ»¸öºǫ́ΪservletµÄFCFµÄÀý×Ó£¨×¢Ò⣺´ËÀýÖÐjs¿ò¼ÜʹÓÃjquery£© ......
session¾ÍÊÇÒ»¸öÈ«¾Ö±äÁ¿£¬ÊÇä¯ÀÀÆ÷Ïß³ÌÔÚ·þÎñÆ÷¶ËµÄ´úÀí¡£web·þÎñ³ÌÐòÖ»Òª´ò¿ª£¬session¾Í»á´æÔÚ£¬µ±ÄãµÚÒ»´Î·ÃÎÊʱ£¬session»á×Ô¶¯ÎªÄã·ÖÅäÒ»¸ösession ID£¬ËùÒÔsessionΪн¨Á¢µÄ£¬ËùÒÔsession.isNew()Ϊtrue¡£µ±ÄãË¢ÐÂÒ³Ãæʱ£¬Õâ¸ösession IDÒ»Ö±´æÔÚ(session.getId()²»±ä)£¬²»»áÏûʧ£¬ËùÒÔsession.isNew()Ϊfalse¡£³ý· ......
ÎÒÊÇÔÚÒÔÏÂÕâÁ½ÖÖÇé¿öÏÂʹÓõ½Õâ¸öÎļþµÄ£º
µ±ÄãÐèÒªÏò·þÎñÆ÷ÉÏ´«Ò»¸öÎļþ£¬µ«ÊÇÕâ¸öÎļþ²¢²»ÔÚÄãµÄ±¾»úÉÏ£¬¶øÇÒÔÚÁíһ̨·þÎñÆ÷ÉÏ£¬µ«ÊÇÄãÓÖûÓб¾Ì¨·þÎñÆ÷µÄÔ¶³Ì×ÀÃæµÄȨÏÞÈÃËüÈ¥ÏÂÔØÄǸöÎļþ£¬ÕâʱÄã¾Í¿ÉÒÔʹÓôËÎļþÈ¥ÏÂÔØ¡£
¶þ¾ÍÊÇÄ¿±ê·þÎñÆ÷µÄÉÏ´«Ëٶȷdz£µÄÂý£¬ÓÚÊÇÎÒ½«ÎļþÏÈ´«µ½ÁËÁíһ̨ÉÏ´«ËٶȽϿìµÄ·þÎñÆ÷ÉÏ£¬ ......