| Author |
Where's my uploaded file?
|
Allen Williams
Ranch Hand
Joined: Sep 04, 2006
Posts: 136
|
|
I am trying to upload a file, and the browser (a Firefox derivative called Iceweasel,distributed with Debian Linux) doesn't seem to be sending the file. The basic form is like this:
<form id="uploadform" action="/members/servlet/MapsAjaxSupport" enctype="multipart/form-data" method="post"> <div class="fileinput"> <input id="pathfileup" type="file" /> <input id="upbut" type="submit" value="Upload" class="formbutton"> </div><!-- fileinput --> </form>
When the request hits my servlet, I iterate through the pieces using the jakarta commons file upload, and never get a file, although I get everything else (added to the form with Javascript). Here is what I'm printing out from the request, using the header map & getting a reader on the request body:
********** Request Header Values Context Path= '' Content Type= 'multipart/form-data; boundary=---------------------------81707749216045394012024245416' Header Name/Values Oct 28 20:50:05: host Oct 28 20:50:05: anw-dev Oct 28 20:50:05: user-agent Oct 28 20:50:05: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/20070310 Iceweasel/2.0.0.3 (Debian-2.0.0.3-1) Oct 28 20:50:05: accept Oct 28 20:50:05: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Oct 28 20:50:05: accept-language Oct 28 20:50:05: en-us,en;q=0.5 Oct 28 20:50:05: accept-encoding Oct 28 20:50:05: gzip,deflate Oct 28 20:50:05: accept-charset Oct 28 20:50:05: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Oct 28 20:50:05: Keep-Alive Oct 28 20:50:05: 300 Oct 28 20:50:05: connection Oct 28 20:50:05: keep-alive Oct 28 20:50:05: referer Oct 28 20:50:05: https://anw-dev/members/trbmap.jsp?tkey=2&mkey=2 Oct 28 20:50:05: cookie Oct 28 20:50:05: userid=frank; pwd=xxxxxxxxxxx; JSESSIONID=7915F7EEB596B0F95C709B9F8AD2A276 Oct 28 20:50:05: content-type Oct 28 20:50:05: multipart/form-data; boundary=---------------------------81707749216045394012024245416 Oct 28 20:50:05: content-length Oct 28 20:50:05: 669 The body of the request follows: Oct 28 20:50:05: -----------------------------81707749216045394012024245416 Oct 28 20:50:05: Content-Disposition: form-data; name="ajaxreq" <null> Oct 28 20:50:05: uppth Oct 28 20:50:05: -----------------------------81707749216045394012024245416 Oct 28 20:50:05: Content-Disposition: form-data; name="name" <null> Oct 28 20:50:05: Path Name. Oct 28 20:50:05: -----------------------------81707749216045394012024245416 Oct 28 20:50:05: Content-Disposition: form-data; name="desc" <null> Oct 28 20:50:05: A description of this path goes here. Oct 28 20:50:05: -----------------------------81707749216045394012024245416 Oct 28 20:50:05: Content-Disposition: form-data; name="mapkey" <null> Oct 28 20:50:05: 7 Oct 28 20:50:05: -----------------------------81707749216045394012024245416 Oct 28 20:50:05: Content-Disposition: form-data; name="closed" <null> Oct 28 20:50:05: on Oct 28 20:50:05: -----------------------------81707749216045394012024245416--
Everything looks perfect, right down to the two "minus" signs terminating the request, but no file. All the documentation says to use "multipart/form-data", so I assume this is OK. Any help would be appreciated. TIA, anw
|
-------<br />Thanks & regards,<br />anw
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56150
|
|
|
Debugging step #1; What happens when you try it with another browser?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Allen Williams
Ranch Hand
Joined: Sep 04, 2006
Posts: 136
|
|
I get the same thing on the Epiphany browser, but it is also using the Gecko engine, I think. I'll try it in IE tomorrow, and post again. Thanks!
|
 |
Emanuel Kadziela
Ranch Hand
Joined: Mar 24, 2005
Posts: 186
|
|
Have you tried using FileUploadBase.parseRequest(javax.servlet.http.HttpServletRequest) from the commons fileupload to get the list of file items?
|
 |
Allen Williams
Ranch Hand
Joined: Sep 04, 2006
Posts: 136
|
|
|
Yes, that is what I'm using. I could print out what happens when I iterate through, but basically, I get everything & no file. What I printed out above is the raw request coming from the browser, which shows the file is not attached.
|
 |
Allen Williams
Ranch Hand
Joined: Sep 04, 2006
Posts: 136
|
|
I didn't get to my office today to try IE or the "canonical" Windows version of Firefox, but will do that tomorrow. Meantime, I'm doing a lot of strange stuff to try to "pretty up" the file upload widget on the page. As you are probably aware, for "security reasons" (the ultimate excuse for making everything a pain in the a** :rolleyes , the file upload input tag is pretty much uncustomizable. Plus, I attach a bunch of other stuff I need to know about to invisible form inputs, so I'm going to try to deconstruct that stuff to the point I only have the file input, then, if that works, add stuff back in until it breaks, and figure it out that way. Thanks, and I'll post my results.
|
 |
Allen Williams
Ranch Hand
Joined: Sep 04, 2006
Posts: 136
|
|
OK, I stripped out everything except the normal, plain file upload input tag, and tried it with both Iceweasel & "canonical" Firefox, and still don't get the file. The content of the request is reduced to:
The body of the request follows: Oct 29 16:36:30: -----------------------------20014300982800--
Nothing. Any thoughts?
|
 |
Allen Williams
Ranch Hand
Joined: Sep 04, 2006
Posts: 136
|
|
OK, I think I found the problem. I fixed it in the stripped down version, but need to put everything else in and see if it still works. On the W3C.org site, I found the following statement:
17.13.2 Successful controls A successful control is "valid" for submission. Every successful control has its control name paired with its current value as part of the submitted form data set. A successful control must be defined within a FORM element and must have a control name.(Emphasis mine)
If you'll notice in the original html I posted, there's no name attribute. When I added that, I got the file section in the request. Thanks for the help, Allen
|
 |
 |
|
|
subject: Where's my uploaded file?
|
|
|