Hi I would like to upload a file from a html form, and use java code in my jsp file to download it to a new location.
I have the html for file uploading all set up, and I know how to set up an inputstream in java, but I do not know how to connect the two i.e. connect the file accessed by the upload form to FileInputStream in my jsp file. The form looks like this: <form method="GET" action="p_enter.jsp"> <INPUT TYPE=FILE NAME=documents SIZE=40> <INPUT TYPE=SUBMIT VALUE=Submit> </form> But where the form is processed, in p_enter.jsp, how do I get the data from the file in FileInputStream? I know about: try { BufferedReader inputFile=new BufferedReader(new inputStreamReader(new FileInputStream(?))); Then I can do something, like write the data out to an outfile }catch(IOException ex1){return;} The above java code works well directly from a local disk - but I am not sure how to do this from a upload link on the web. When I upload the file, I would like to specify the path on the server where I want to download the file, check if a file with such a name already exists, and if so, insert a number before the file extension eg. myfile.doc already exists, so the next myfile.doc automatically becomes myfile1.doc. Then I would like to save the file, and keep the path and filename available to write to a MySQL database. Writing to the MySQL database is all under control, but I can't seem to find a way to upload the file, check and (if necessary change) the extension and lastly download the file to a location on the server. Could someone help me out with this? A code example to get me started would be very welcome. Note that I am using apache with tomcat on a linux webserver and would like to use jsps. I would prefer to write the code myself rather than making use of pre-existing code. This is because I would like to retain control over what I am doing. Thanks very much. Hugo -- Dr Hugo Bouckaert Systems and Programming Engineer GeoInformatics Exploration Australia P/L 57 Havelock St West Perth, WA 6005 PO Box 1675, West Perth 6872 Ph: 61 08 9420 7400 Fax: 61 08 9226 1299 www.geoinformex.com ------------------------------------------------------------------------ This email and any attachments may be confidential or legally privileged. If you received this message in error or are not the intended recipient, you should destroy the e-mail message and any attachments or copies, and you are prohibited from retaining, distributing, disclosing or using any information contained herein. Please inform us of the erroneous delivery by return e-mail. Thank you for your cooperation. =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com