uploading multiple files 'post' not working on server (works fine on local)

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 <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) <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 MultipartRequest multi =new MultipartRequest(request,".");

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 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

[2269 byte] By [uninvitedma] at [2007-11-27 5:26:28]
# 1

>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).

And there is your issue.

Java code runs on the server.

Therefore when using the java.io packages, you are accessing the servers file system.

You can not access the client's file system from the server using java code (and thank god for that. it would be a HUGE security hole)

The reason it works on your local machine is because the client is also the server, and the file you selected on the client just happens to be there on the server as well.

There is a reason people have written the "traditional" uploading method. Because that is the only one available when dealing with a remote client to the server.

evnafetsa at 2007-7-12 14:47:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Ok thanks for the reply -- how is a good way to go about this then?

My understanding was you had to do 2 steps -- upload the file to the server and *then* write it to a server location. I'm trying to do the first step but not the second different.

But even when I don't have that code implemented, the 'post' on the server returns a blank page.. do u hav any suggestions for that or things I can check?

thanks

uninvitedma at 2007-7-12 14:47:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...