It won't work. You will know what would happen if you try it.
matt
----- Original Message -----
From: "Sohaila Roberts" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, September 17, 2001 10:44 AM
Subject: InputStreams
> Hi, I know there is an example of uploading files via servlets in the
> o'reilly servlet programming book, I was just wondering what would happen
> if i had the following html page
>
> <FORM ACTION="UploadServlet" METHOD=POST>
> Select the file to upload <INPUT TYPE=FILE NAME=filename><br>
> <INPUT TYPE=SUBMIT>
> </FORM>
>
> and UploadServlet contained the following
>
> public void doPost(HttpServletRequest req, HttpServletResponse resp)
> throws ServletException, IOException
> {
> String filename = req.getInputStream().getParameter("filename");
> File f = new File(filename);
> try {
> FileInputStream fin =
> (FileInputStream)req.getInputStream();
> FileOutputStream fout =
> new FileOutputStream(f);
> int ch;
> while((ch = fin.read())!=-1) {
> fout.write(ch);
> }
> fin.close();
> fout.close();
> //stick f in database or whereever..
> } catch (IOException e) {}
> }
>
> would this work to upload a file such as .doc or .wpd or .sdw type files
> or any other files for that matter?
>
>
> Thanks!
> Sohaila
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html