%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" import="java.io.*" import="java.util.*" import="org.apache.commons.fileupload.*" errorPage="" %><%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <% FileItem photo=null; String picture_id = ""; String real_pic_name = ""; int count = 0; boolean isMultipart = FileUpload.isMultipartContent(request); if (isMultipart) { // Create a new file upload handler DiskFileUpload upload = new DiskFileUpload(); // Set upload parameters upload.setSizeMax(500*1024); // 100Kb //upload.setRepositoryPath("c:/temp"); // Parse the request List items = upload.parseRequest(request); Iterator it = items.iterator(); while (it.hasNext()) { FileItem fitem = (FileItem) it.next(); if (!fitem.isFormField()) { //fitem.write(new File(getServletContext().getRealPath("/")+"/realtors/r"+request.getParameter("realtor_id")+".jpg")); photo = fitem; //test = getServletContext().getRealPath("/"); } else { String name = fitem.getFieldName(); if("picture_id".equals(name)) picture_id = fitem.getString(); } } if(photo!=null) { real_pic_name = picture_id; String img1 = "pictures/"+ picture_id + ".jpg"; String realPathToImage = application.getRealPath(img1); java.io.File imageFile = new java.io.File(realPathToImage); if(imageFile.exists()) { real_pic_name = picture_id + "_0"; count++; do { img1 = "pictures/"+ real_pic_name +".jpg"; realPathToImage = application.getRealPath(img1); imageFile = new java.io.File(realPathToImage); if(imageFile.exists()) { real_pic_name = picture_id + "_" + count; count++; } }while(imageFile.exists() && count<14); } photo.write(new File(application.getRealPath("pictures")+"/"+real_pic_name+".jpg")); count++; } } else { picture_id = request.getParameter("picture_id"); String img1 = "pictures/"+ picture_id + ".jpg"; String realPathToImage = application.getRealPath(img1); java.io.File imageFile = new java.io.File(realPathToImage); if(imageFile.exists()) { real_pic_name = picture_id + "_0"; count++; do { img1 = "pictures/"+ real_pic_name +".jpg"; realPathToImage = application.getRealPath(img1); imageFile = new java.io.File(realPathToImage); if(imageFile.exists()) { real_pic_name = picture_id + "_" + count; count++; } }while(imageFile.exists() && count<14); } } %>
<% if(count>0) {%>
<%}%>
|
<% if(count>1) {%>
<%}%>
|
<% if(count>2) {%>
<%}%>
|
<% if(count>3) {%>
<%}%>
|
<% if(count>4) {%>
<%}%>
|
<% if(count>5) {%>
<%}%>
|
<% if(count>6) {%>
<%}%>
|
<% if(count>7) {%>
<%}%>
|
<% if(count>8) {%>
<%}%>
|
<% if(count>9) {%>
<%}%>
|
<% if(count>10) {%>
<%}%>
|
<% if(count>11) {%>
<%}%>
|
<% if(count>12) {%>
<%}%>
|
<% if(count>13) {%>
<%}%>
|
<% if(count>14) {%>
<%}%>
|