• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

Upload attachment using Java

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need coding for uploading document:

Attachment size : <2mb
Attachement format : pictures or pdf

Kindly please help me to resolve the issue

 
Sheriff
Posts: 67734
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where's your code? What problems are you having with it?
 
Sheriff
Posts: 22769
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Upload how? HTTP, FTP, through email?
 
ruba sampath
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Upload from my local PC and to store the document or picture in the database.
 
Rob Spoor
Sheriff
Posts: 22769
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use a third part library like HttpClient to upload files to a web server.
 
Marshal
Posts: 27987
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you looking for client code which can upload data through some protocol (HTTP, FTP, etc) to a server? Or are you looking for server code which can receive HTTP uploads?
 
ruba sampath
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looking for client code which can upload data through some protocol (HTTP, FTP, etc) to a server
 
Paul Clapham
Marshal
Posts: 27987
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay. Client-side code then. But the code you use will depend on the protocol required by the server. So you should find out what that is.
 
Rob Spoor
Sheriff
Posts: 22769
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul's right. The way files are uploaded in HTTP and FTP is quite different, and for SMB (a.k.a. Windows file sharing), NFS or SCP it's again completely different.

For HTTP you'll first need a page that can handle the file upload; a servlet, JSP page, PHP page, ASP page, etc. The HttpClient library I mentioned can then handle the rest.
For FTP you can use Apache Commons Net or JvFTP.
For SMB you can use regular java.io.File if the rights allow it, or JCIFS otherwise.
For SCP you can use JSch.

Of course these aren't the only libraries to use, but they do seem to be the most commonly used.
 
ruba sampath
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Paul. I need to upload the pdf or picture through local PC to database..
 
Rob Spoor
Sheriff
Posts: 22769
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll need a table with a BLOB / binary / varbinary column. You then use PreparedStatement to insert / update a record in that table; PreparedStatement has a few setBinaryStream and setBlob methods and a setBytes method you can use for that.
 
ruba sampath
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you

I have inserted the record in the DB. But before inserting i have to find the file size in JSP using javascript without using ActiveXObject. Please Send me the code ASAP.
 
Rob Spoor
Sheriff
Posts: 22769
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ruba sampath wrote:Please Send me the code ASAP.


We are NotACodeMill. And please EaseUp.
 
ruba sampath
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rob,

You have understand wrongly. Send me the code in the sense "teach me how to proceed the concept"... I knoe code ranch is for beginners to learn.
 
Rob Spoor
Sheriff
Posts: 22769
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think this information is available through JavaScript. It's quite limited in what it can and cannot do with the file system.
 
ruba sampath
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rob
 
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic