469,626 Members | 994 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

JSP - uploading multiple files 'post' not working off server (works fine on localhost

I'm making a JSP page where (ideally) you select files to upload, each selected file is added to a listbox. The form is submit, (along with some other parameters), and the files are uploaded. They arent uploaded (written) tradionally to a server, I just need the file's input stream to pass to a method elsewhere (which will upload to a database).

The page has a file-input type to locate files to upload. Once a file is selected (onChange()), the filename is added to a listbox
Expand|Select|Wrap|Line Numbers
  1. <SELECT NAME="listfiles" MULTIPLE>
and there is a button which submits the form. The form submits to itself (so it will submit to the same jsp page)
Expand|Select|Wrap|Line Numbers
  1. <FORM NAME="formname" ACTION="uploadpage.jsp" METHOD="post" enctype="multipart/form-data">
On my local machine, I can open the page, select a file and submit -- the page loads fine. When on the web server, when I submit -- the page will go have an error -- the typical 'this page cannot be displayed' error which is shown a page's cant be found. I have absolutely no idea why! To me, it should simply load that page again. Some of the time it does this, and other times (most times) it just turns blank -- I can't work out why.

Similarly when I try to submit (on local machine) and just take the file-input value, eg with
Expand|Select|Wrap|Line Numbers
  1. MultipartRequest multi = new MultipartRequest(request, ".");
  2. params = multi.getFileNames();
and enumerate through and display the value of any files -- it shows the browse button's name but its value is always 'null' even though something was entered there. This won't be a problem if I don't need to get the filename through here to upload it as the other parameters (from the select box) come through fine with
Expand|Select|Wrap|Line Numbers
  1. Enumeration params = multi.getParameterNames();
where name="listfiles"

This is very frustrating and I really would appreciate help, particularly if I'm going about this the wrong way. Is it even possible to use filenames supplied in the listbox to get a local file's input stream or does it have to be a file-input type.

Thanks a lot
May 24 '07 #1
0 1497

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Tim Mulholland | last post: by
2 posts views Thread by tshad | last post: by
2 posts views Thread by FusionGuy | last post: by
4 posts views Thread by Ramakrishnan Nagarajan | last post: by
2 posts views Thread by AAJ | last post: by
5 posts views Thread by Chris | last post: by
1 post views Thread by wenqiang7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.