Upload Applet

M

McK

Hi all, i need to make a little applet for my website to upload file (5/8mb)
in a specific directory.
I saw some applet in internet but they're all shareware and i can upload
only 2mb, or i ust register to use it.
Someone can help me, i don't know code to make it up.

Thanks, McK
 
A

Andrew Thompson

I saw some applet in internet but they're all shareware and i can upload
only 2mb, or i ust register to use it.

So register. What do you think
Java programmers eat? ..air?
 
M

McK

Register... they want 400$, and my university professor want source code of
my program!! :D
So i think it's better if i make an applet and not buy another one! :D

McK
 
A

Andrew Thompson

<top-posting corrected..>
Register... they want 400$,

What's the URL?
..and my university professor want source code of
my program!! :D

Are you joking *now*, or were you joking
before when you asked?
"Hi all, i need to make a little applet for
my website to upload file (5/8mb)
in a specific directory."

"Someone can help me, i don't know code to make it up."

If you are serious that you need to write this
but do not know where to start, begin here..
<http://www.physci.org/codes/javafaq.jsp#cljh>

But have a good long look through that
document first and follow the links to
'smart questions' as I doubt you will get
far without it.

F'Ups set to c.l.j.help

HTH
 
J

John Davison

McK said:
Register... they want 400$, and my university professor want source code of
my program!! :D
So i think it's better if i make an applet and not buy another one! :D

Um, then what does "I don't know code to make it up" mean?

I'm currently finishing up a project for a digital photography lab that
allows people to upload any amount of data into specified directories.
It allows for multiple users, password, full drag and drop, etc...

It's not free, though, especially if you want the source code. But I
won't charge $400 either :)

- john

Remove all the capital letter A's below to email me.

(e-mail address removed)
 
M

mromarkhan

McK said:
Hi all, i need to make a little applet for my website to upload file (5/8mb)

Peace be unto you.

Try http://jvftp.sourceforge.net/
Features (copied from web site):
-Uploads / downloads files
-Recursive directory uploads
-Concurrent data transfers
-Both passive / active data transfer modes
-Swing components for browsing files and directories
-AWT components for browsing files and directories

This ftp library is licensed under the GPL
according
to the homepage (http://jvftp.sourceforge.net/)
or LGPL according to the sourceforge
page (http://sourceforge.net/projects/jvftp).

Here is info about the GPL
http://www.gnu.org/copyleft/gpl.html

Anyways,
This example illustrates an unsigned version
that works only on
Microsoft Internet Explorer JVM 1.1.
Enter your password first.
Enter a file name in the north box
Enter your content in the center box.
I successfully upload 855 kb of text.

On Server
jvftplib.cab
FtpApplet.class
FtpApplet$DialogFrame.class
Ftp.html
COPYING (license)

1. Downloaded jvftp-bin-0_72.zip
http://sourceforge.net/projects/jvftp

2. Renamed jvftp-AWT.jar to jvftp-AWT.zip so I can easily unzip it.

3. Created Comparable.java (package java lang)
Obtained it from
http://www.opensource.apple.com/darwinsource/10.3/gccfast-1614/libjava/java/lang/Comparable.java
This is licensed under the GPL

4. Compiled it using target since Internet Explorer has 1.1 jvm
javac -target 1.1 Comparable.java

5. Placed it in C:\downloads\jvftp-bin-0_72\jvftp\lib\jvftp-AWT\java\lang

6. Created a CAB file since Internet Explorer does not support jar
cabarc -r -p -P downloads\jvftp-bin-0_72\jvftp\lib\jvftp-AWT\ n jvftplib.cab C:\downloads\jvftp-bin-0_72\jvftp\lib\jvftp-AWT\*.*
-r stands for recursive
-p keeps the directory structure
-P strips the path from the absolute path to create a relative path
n create new cab
See reference to obtain cabarc.exe

7.Created Test Applet
<code>
import java.awt.*;
import java.applet.*;
import java.util.*;
import java.net.*;
import java.io.*;
import java.text.*;
import cz.dhl.io.*;
import cz.dhl.ftp.*;

public class FtpApplet extends Applet
{
private String username="";
private String password="";
private String host="";
TextArea textDisplay = new TextArea(80,24);
TextField fileName = new TextField(10);
public void init()
{
host = getParameter("host");
username = getParameter("username");
new DialogFrame("Enter Password");
setLayout(new BorderLayout());
add("North", fileName);
add("Center",textDisplay);
add("South", new Button("Post"));
}
public boolean action(Event e, Object arg)
{
String label = (String)arg;
if (label.equals("Clear"))
{
textDisplay.setText("");
}
else if (label.equals("Post"))
{
doPost();
}
return true;
}
public void doPost()
{
FtpOutputStream os = null;
String line;
FtpConnect cn = FtpConnect.newConnect("ftp://"+host+"/");
cn.setUserName(username);
cn.setPassWord(password);
Ftp cl = new Ftp();
try
{
cl.connect(cn);
FtpFile file = new FtpFile(fileName.getText(), cl);
System.out.println("From: " + file.toString());
boolean append = true;
os = new FtpOutputStream(file,append);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));
line="<pre>"+textDisplay.getText()+"</pre>";
bw.write(line,0,line.length());
bw.close();
}
catch (IOException e)
{
System.out.println(e);
}
finally
{
if (os != null)
{
try
{
os.close();
}
catch (IOException e)
{
}
cl.disconnect();
}
}
textDisplay.setText("");
}
public class DialogFrame extends Frame
{
TextField inPassword = new TextField(10);
DialogFrame(String title)
{
super(title);
inPassword.setEchoChar('*');
setLayout(new FlowLayout());
add(inPassword);
add(new Button("OK"));
pack();
show();
}
public boolean action(Event e, Object arg)
{
String label = (String)arg;
if (label.equals("OK"))
{
password=inPassword.getText();
dispose();
}
return true;
}
}
}
</code>

8. Compile using target since 1.1 jvm
javac -classpath "C:\downloads\jvftp-bin-0_72\jvftp\lib\jvftp-AWT.jar" -target 1.1 FtpApplet.java

10. Created the Ftp.html page which uses Cabbase so it downloads everytime.
A better solution is Useslibrary (see references),
which allows a archive to be download once and
persist.
<html>
<head>
</head>
<body topmargin=0 leftmargin=0>
<applet code=FtpApplet.class width=320 height=240
archive="jvftplib.jar" codebase=".">
<param name="cabbase" value="jvftplib.cab">
<param name="username" value="mromarkhan">
<param name="host" value="members.rogers.com">
</applet>
</body>
</html>



-- References
HOW TO: Create a Cab file for java
Packaging ActiveX Controls
http://msdn.microsoft.com/library/default.asp?url=/workshop/components/activex/packaging.asp

HOW TO: Downloading cabarc.exe
Need to download Cabarc which is in the Platform SDK bin directory
or
Microsoft Knowledge Base Article - 310618
http://support.microsoft.com/default.aspx?scid=kb;en-us;310618

HOW TO: Permanently persist java archives for faster loading
"The important feature to note regarding Useslibrary is that it will install the package on the user's machine permanently until they are removed by the user, whereas the Cabbase parameter will simply download and use the CAB every time the user hits the
179652 - HOWTO: Deploy Java in Internet Explorer 4.0 and Netscape 4.0:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;179652

HOW TO: Using jar files in Internet Explorer
You can't, you need to use cab
So instead of archive you use a param which Internet Explorer recognizes
179652 - HOWTO: Deploy Java in Internet Explorer 4.0 and Netscape 4.0:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;179652

HOW TO: Using FTP with Java 1.1
Java FTP Client Library:
http://jvftp.sourceforge.net/

HOW TO: Laying out components along the borders in Java 1.1
add("NORTH", component);
Trail: Creating a User Interface (AWT Only)
http://java.sun.com/docs/books/tutorial/ui/index.html

HOW TO: Including multiple jar files in an applet.
"archive = uri-list [CT]
This attribute specifies a comma-separated list of
URIs for archives containing classes and
other resources that will be 'preloaded'."
13 Objects, Images, and Applets
http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.4

HOW TO: Compiling applets on Internet Explorer
HOW TO: Resolving Class Not Defined errors with Applets in Internet Explorer
javac -target 1.1 MyApplet.class
http://java.sun.com/j2se/1.3/docs/tooldocs/win32/javac.html

Have a good day.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top