Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading file from client machine

 
sam jose
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can my Web application read a .txt file from the client machine and execute some DML statements to update the Database ?
Any comment is appreciated.
Thanks.
 
pawank gupta
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u can send ur file as attachement with ur post request(multipart) to server, from wher u can read it

or

make a url connection and read the file at server end
 
Manish Sridharan
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TRY USING APACHE FILE UPLAOD TAG TO UPLOAD THE ATTACHMENTS. IT IS EASY TO USE..

THANKS


GAURAV NIGAM
 
sam jose
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think sending file as 'attachment (multipart)'/'apache file upload' will create a physical presence of the file in the server.
Correct me if I am wrong.
Can I read the file without creating a physical presence of the file in the server?

Thanks for the prompt reply
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by samjose samjose:
I think sending file as 'attachment (multipart)'/'apache file upload' will create a physical presence of the file in the server.
Correct me if I am wrong.
Can I read the file without creating a physical presence of the file in the server?


No. Not necessarily. We can read the file without writing it back to somewhere. It would be persisted if you want it to like write it somewhere on the server.

By the way, getting update statement from the file, which resides on the client machine . Any particular reasons?
 
pawank gupta
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no u cant read file without saving it u programmetically save and delete it
 
sam jose
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Adeel,

Is it really possible, with out storing the file ?
Can you give the details.

I request comments from Ranchers.

Thanks.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"samjose samjose",
Welcome to the Ranch!

We're a friendly bunch, but we take our display names very seriously.

We require display names to be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and fix your display name since accounts with invalid display names get deleted.

thanks
Dave.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by pawank gupta:
no u cant read file without saving it u programmetically save and delete it


Agreed. If you are particularly talking about Commons Fileupload. Otherwise we can implement it on our own.

Never tried but it sounds like possible to use getInputStream()/getOutputStream in this case, using Commons.
[ July 04, 2006: Message edited by: Adeel Ansari ]
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Indeed.

From Fileupload Using Guide

"With uploaded files, you generally will not want to access them via memory, unless they are small, or unless you have no other alternative. Rather, you will want to process the content as a stream, or write the entire file to its ultimate location. FileUpload provides simple means of accomplishing both of these.


Note that, in the default implementation of FileUpload, write() will attempt to rename the file to the specified destination, if the data is already in a temporary file. Actually copying the data is only done if the the rename fails, for some reason, or if the data was in memory.

If you do need to access the uploaded data in memory, you need simply call the get() method to obtain the data as an array of bytes.

[ July 03, 2006: Message edited by: Adeel Ansari ]
 
sam jose
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to you all.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pawank gupta,
Welcome to JavaRanch!

In an effort to help you get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.

In particular please see: UseRealWords

Abbreviations such as "u" or "ur" in place of "you" and "you are"
or "you're" confound language translation software making it hard
for our non-English speaking members to read your posts.

Again, welcome to JavaRanch and good luck with your question.
-Ben


As to your comment.
Jakarta's commons/fileupload will allow you to read the uploaded file into memory and work with it without having to save it to disk.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic