Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

Applet won't delete temp files

Thread view: 
Dustin - 29 Jan 2006 17:37 GMT
I have created a web site for my family that allows them to have online
photo albums.  For this website, I created a Java Applet to aid in
uploading images to the photo albums.  The user chooses images from
their computer to upload (the Applet is contained in a signed jar file
so that it can have access to the user's file system).  Then they click
on a button to begin the upload.  Each picture is scaled down to a
standard size before the upload takes place.  The new scaled image is
stored as a java temp file on the user's hard disk and then uploaded to
the server via FTP.  The problem I am haveing is this- When I run the
application from a JFrame, everything works fine and the temp files get
deleted.  However, when I run it as an applet from the web, almost
everything works fine.  The image gets scaled and the temp file gets
produced.  That temp file is successfully copied to the server.  But
then the temp files are never getting deleted!  So it fills up the
user's hard drive with copies of the images they are uploading.  Here
is a snippet of the basic idea of how I am doing this.  The code is
obviously very incomplete.  It is just to give you an idea of what is
going on.

**** CODE ****

File imgFile = new File("path/to/file.jpg");
imgFile = scaleDownImage(imgFile);
ftpClient.stor(new FileInputStream(imgFile.getAbsolutePath());
imfFile.delete();

**** END CODE ****

Thank you in advance for any help.
Dustin
Dustin - 30 Jan 2006 15:28 GMT
Hey, I figured out what was wrong and thought I would post what it was
in case anyone has this same problem.  The FTP stor procedure required
an input stream which I created from the file.  Then, in order to
delete the file, I needed to close the input stream, which I was not
doing.  Simple answer.
Roedy Green - 30 Jan 2006 22:14 GMT
> For this website, I created a Java Applet to aid in
>uploading images to the photo albums.

To create files on the client machine or to delete them your Applet
must be signed.  If it is not, I am baffled how you got as far as you
did.

See http://mindprod.com/jgloss/signedapplets.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.