• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cant get at it...like. i feel like tantalus

 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
In the code below for input type=file, the js onchange grabs the file location of the selected file, however when I post it it is not in either the session or request param. (Further below is the jsp). What is odd is when I use the DOM Inspector in Mozilla the #text element for the input element file1Name shows " " for the value. However the input element labeled path does show the correct value.

How do I get the value of the selected file into a parameter accessible by an action or jsp?



[CODE]
<%@ page errorPage="UploadReview_error.jsp" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>

<jsp:useBean id="uploader" class="filesDM.helper.UploadBean" scope="session" />

<jsp:setProperty name="uploader" property="dir"
value="<%=application.getInitParameter(\"save-dir\")%>" />

<jsp:setProperty name="uploader" property="req" value="<%= request %>" />
<jsp:setProperty name="uploader" property="path" value="<%=request.getParameter("file")%>"/>
<%=request.getParameter("file") %>

<html>
<head><title>file uploads</title></head>
<body>
From the session the websiteID= <c ut value="${websiteID}" default="not in session"/><br />
From the session file1= <c ut value="${file1}" default="no file1 from session"/><br />
From the session file1Name= <c ut value="${file1Name}" default="no file1Name from session"/><br />
From the parameters varstatus= <c ut value="${param.varStatus}" default="not a parameter"/> state= <c ut value="${param.state}"/>.<br />
From the parameters file1= <c ut value="${param.file1}" default="no file1 from parameters"/><br />
From the parameters file1Name= <c ut value="${param.file1Name}" default="no file1Name from parameters"/><br />

<h2>Here is information about the uploaded files</h2>

<jsp:getProperty name="uploader" property="uploadedFiles" />


</body>
 
Paul Clapham
Sheriff
Posts: 21117
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe it's a security feature? But anyway, you get the name of the file as part of the <input type="file"> entry, so I don't see why you are trying to duplicate that information in your request.
 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Clapham:
Maybe it's a security feature? But anyway, you get the name of the file as part of the <input type="file"> entry, so I don't see why you are trying to duplicate that information in your request.


Hi Paul
That is the problem, I cant get it from the request.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to parse the multipart request. There are some third party libraries to help you do that, like the Jakarta Commons FileUpload :
http://jakarta.apache.org/commons/fileupload/index.html

There's a tag library called "Xephyrus File Upload Tag Library", but I can't access their webpage...
[ May 29, 2006: Message edited by: Satou kurinosuke ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic