Link to home
Start Free TrialLog in
Avatar of suprapto45
suprapto45Flag for Singapore

asked on

File Upload

Hi,

I am using Tomcat 5.5. If my clients give me the list of files in his machine, is there any way we can upload the file to server (Tomcat 5.5)? Preferably, the uploading is in the same request. I will try to google it later on but I currently am too busy with other things.

If you can provide me with the URL, that would be good.

David
Avatar of suprapto45
suprapto45
Flag of Singapore image

ASKER

Oh yes,

We can't really use the fileupload component as the number of files are not fixed.

David
Avatar of CEHJ
You need to use an applet to upload several files at a time (unless you use multiple upload form elements)

http://www.jupload.biz/
you can't return mutltiple file in one request response
use a servlet that zips up the required files and returns the zip to th e the client.
Sorry CEHJ and objects

I just returned to office. Basically, without the fileupload like <input type="file"..>, is there any other way we can put the file into request?

David
I was looking at the possibility using XmlHttpRequest but no luck. Another option is using ADODB.Stream of Microsoft but I do not want to do that ;) - I think you all know why.

David
You could use a POST request, but then you would have to zip them
Thanks CEHJ,

>>"You could use a POST request"
but without using tbe <input type="file"..> within the <form></form>. Is it possible to send it to request by POST?

David
Well i was thinking more of having no form at all (if that's acceptable)
SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi CEHJ,

That is acceptable. But I still can't think of any way to put this *stream* of file to POST. Can you share your idea?

David
Hi girionis,

Thanks for your comments. That is a good suggestion but I prefer to have a look at what I am discussing with CEHJ first. If that is not possible then I would go for your suggestion ;).

David
Yeap, no problem. If you decide to go with my suggestion and you also want some help with the JavaScript let me know and I will do my best :)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That is interesting. Let me try that out CEHJ

David
I am just getting a little *blur*

// data would be key1=value1
String data = URLEncoder.encode("key1", "UTF-8") + "=" + URLEncoder.encode("value1", "UTF-8");

If the value1 is supposed to be the *stream* of the file uploaded instead of String. What would happen there as data is String?

David
>>"What would happen there as data is String?"
What should we do?

David
> What would happen there as data is String?

It should be the same, just use one of the other methods that write the data as stream.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Correction:

>>Enumeration<?> enum = Collections.enumeration(files);

should have been

Enumeration<FileInputStream> enum = Collections.enumeration(files);
Another correction (i'm a bit tired ;-)):

that will concatenate the files. Just do a normal ZipFile and add entries
Thanks

I will have a try on it

David
Excellent. Thanks everyone. I think that I have grabbed the concept now ;).

David
:-)
Isn't that what I suggested oiriginally, what exactly did u decide to use?
Sorry objects,

I just read my mail. Well, I decided to use the combination of FileUpload, HttpClient of the Jakarta Common as well as the suggestion of CEHJ. I have not yet implemented it as this project happens in the coming weeks. However, I may not use the zip as I was thinking of some other alternatives.

I have to say that all the concepts are here ;).

David