?
Solved

Applet - Drag & Drop, and Upload files

Posted on 2006-04-13
10
Medium Priority
?
920 Views
Last Modified: 2008-03-17
Hi,

I wish to be able to drag a file from my hard disk onto an applet within the browser, and have the applet then upload that file to the web server (or rather, pass it to a PHP file - via HTTP).

How can I do this?

I imagine the applet would need to be signed, right?

When the user drags and drops a file onto a component, how can I detect this? And then, how can I read this file up to the server via HTTP?

Thanks.
0
Comment
Question by:InteractiveMind
10 Comments
 
LVL 14

Assisted Solution

by:hoomanv
hoomanv earned 1200 total points
ID: 16444121
> I imagine the applet would need to be signed, right?
YES

> how can I read this file up to the server via HTTP?
create a URLConnection
read your file
send a POST request to server with Content-Type = "multipart/form-data"
write the file to the outputStream of connection
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 16444124
do you want to handle the uploaded file at server side too ?
0
 
LVL 25

Author Comment

by:InteractiveMind
ID: 16444142
> create a URLConnection
> read your file
> send a POST request to server with Content-Type = "multipart/form-data"
> write the file to the outputStream of connection

I'm kinda new to applets... could I get a quick example please?


> do you want to handle the uploaded file at server side too ?
Using a PHP script, I intend to, yes... unless there's an easier way?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 14

Assisted Solution

by:hoomanv
hoomanv earned 1200 total points
ID: 16444160
0
 
LVL 25

Author Comment

by:InteractiveMind
ID: 16444175
Wicked.
BTW, what's the ' ****4353 ' stuff all about?
0
 
LVL 8

Assisted Solution

by:colr__
colr__ earned 400 total points
ID: 16444183
The applet will require signing, yes.

Drag and drop is tricky to get working, but you can find info on it here: http://java.sun.com/docs/books/tutorial/dnd/index.html

For info on applets, see this link: http://java.sun.com/docs/books/tutorial/deployment/applet/

There is very little difference between an applet and an application, just some things youll have to remember - the lifecycle is different, restricted resourcse access for security ...

colr__
0
 
LVL 25

Author Comment

by:InteractiveMind
ID: 16444190
Yer, I've got the drag and drop thing working now.
Will have a play with implementing that multipart upload stuff.

Cheers.
0
 
LVL 14

Assisted Solution

by:hoomanv
hoomanv earned 1200 total points
ID: 16444204
> BTW, what's the ' ****4353 ' stuff all about?

it is called boundary. it distinguishes different parts of request

could be more helpful

http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=23&t=002430
0
 
LVL 14

Accepted Solution

by:
hoomanv earned 1200 total points
ID: 16444276
nice approach for Multipart Form File Upload
http://forum.java.sun.com/thread.jspa?forumID=31&threadID=451245
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 400 total points
ID: 16452023
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question