• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help needed for File Uploading code...

 
Shalini Chandel
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,

I need a help. I had made a swing component for file drag and drop. I used JTabbedPane and when user drag any file from FileChooser or Local Desktop Location and drop it to the Tabbed Pane, It displays the contents of the file on a tab.
Program is working perfectly fine.

Now what i want, if any user drag the file and drops it over the component, It should display the name of the file instead of displaying the entire contents. Basically this code is for Uploading the file to the server.

Any sort of help or guidance or clue...most welcome..

Thanx a lot..

Regards
Shalini
 
Mahesh x Bogadi
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can open a Socket to the Server and Write the file content to the output stream.

I assume displaying the filename must be easy.
 
Ravi Sathish
Ranch Hand
Posts: 131
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shalini,

I dunno exactly what you are looking for but the following worked for me:

1> add a TransferHandler to your JComponent say JTree or JTable


2> make myTransferHandler extend TranferHandler and overload importData()


Hope this helps...
 
Shalini Chandel
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx a lot Ravi....
I tried that and it works fine...
What I want was How the file would be uploaded to the server...I guess i have to do socket programming for that...

regards,
Shalini
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic