@SuppressWarnings("rawtypes")
	private void handleMultipartRequest(HttpServletRequest request,
			HttpServletResponse response, HttpSession s) throws IOException {
		ServletFileUpload servletFileUpload = new ServletFileUpload(
				new DiskFileItemFactory());
		String ret = "";

		// Extract file from request
		try {
			List fileItemsList = servletFileUpload.parseRequest(request);
			String optionalFileName = "";
			FileItem fileItem = null;

			Iterator it = fileItemsList.iterator();
			while (it.hasNext()) {
				FileItem fileItemTemp = (FileItem) it.next();
				if (fileItemTemp.isFormField()) {
					if (fileItemTemp.getFieldName().equals("filename"))
						optionalFileName = fileItemTemp.getString();
				} else
					fileItem = fileItemTemp;
			}

			if (fileItem != null) {
				String fileName = fileItem.getName();

				/* Save the uploaded file if its size is greater than 0. */
				if (fileItem.getSize() > 0) {
					if (optionalFileName.trim().equals(""))
						fileName = FilenameUtils.getName(fileName);
					else
						fileName = optionalFileName;

					String path = getServletContext().getRealPath("temp")
							+ (getServletContext().getRealPath("temp").contains("/") ? "/"
									: "\\");
					File saveTo = new File(path + fileName);
					// Store file to temppath
					fileItem.write(saveTo);

					FTPConnectionManager ftpconmgr = (FTPConnectionManager) request
							.getSession().getAttribute("connectionmanager");

					// Upload file to server
					boolean result = ftpconmgr.uploadFile(s.getAttribute("currentfolder")
							.toString(), fileName, saveTo.getAbsolutePath());
					fileItem.delete();
					// Return message to IFRAME
					if (result) {
						ret += "<div id=\"status\">success</div>";
						ret += "<div id=\"message\">Successfully Uploaded</div>";
						// return the upload file
						ret += "<div id=\"uploadedfile\">" + fileName + "</div>";
					} else {
						ret += "<div id=\"status\">failed</div>";
						ret += "<div id=\"message\">There is already such a File</div>";
					}

				}
			}
		} catch (Exception e) {
			ret += "<div id=\"status\">failed</div>";
			ret += "<div id=\"message\">" + e.getMessage() + "</div>";

		} finally {
			response.getOutputStream().println(ret);
		}
	}