You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Caroline Jen <ji...@yahoo.com> on 2004/10/04 22:50:59 UTC

How To Upload Files from Clients' Machine?

In my JSP I have this:

code:
-------------------------------------------------------

     <input type="file" name="filename">

-------------------------------------------------------

for visitors of the web page to browse their PCs'
directories to select a file to upload (when the
Submit button is clicked).  The files can be .doc,
.txt, .pdf, .jpg, ..., etc.  However, I do not have to
convert files into certain format.  I simply retrieve
them from clients' machine and store them into a
database.  Later on, clients can ask to view those
files in their original format.

What appears in the text field:

    <input type="file" name="filename">

will be a file name. How do I get both the file name
and the content of that file to be saved in the
database? 


		
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How To Upload Files from Clients' Machine?

Posted by Jay Miller <he...@gmail.com>.
Make sure you've set the enctype attribute on your form tag to be
"multipart/form-data"


On Mon, 4 Oct 2004 13:50:59 -0700 (PDT), Caroline Jen
<ji...@yahoo.com> wrote:
> In my JSP I have this:
> 
> code:
> -------------------------------------------------------
> 
>      <input type="file" name="filename">
> 
> -------------------------------------------------------
> 
> for visitors of the web page to browse their PCs'
> directories to select a file to upload (when the
> Submit button is clicked).  The files can be .doc,
> .txt, .pdf, .jpg, ..., etc.  However, I do not have to
> convert files into certain format.  I simply retrieve
> them from clients' machine and store them into a
> database.  Later on, clients can ask to view those
> files in their original format.
> 
> What appears in the text field:
> 
>     <input type="file" name="filename">
> 
> will be a file name. How do I get both the file name
> and the content of that file to be saved in the
> database?
> 
> _______________________________
> Do you Yahoo!?
> Declare Yourself - Register online to vote today!
> http://vote.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 



-- 
Yup.  Jay.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How To Upload Files from Clients' Machine?

Posted by Craig McClanahan <cr...@gmail.com>.
There's more to file upload than just getting the <input> element
right.  As usual, Google has links to lots of useful information:

http://www.google.com/search?q=struts+file+upload

Craig


On Mon, 4 Oct 2004 13:50:59 -0700 (PDT), Caroline Jen
<ji...@yahoo.com> wrote:
> In my JSP I have this:
> 
> code:
> -------------------------------------------------------
> 
>      <input type="file" name="filename">
> 
> -------------------------------------------------------
> 
> for visitors of the web page to browse their PCs'
> directories to select a file to upload (when the
> Submit button is clicked).  The files can be .doc,
> .txt, .pdf, .jpg, ..., etc.  However, I do not have to
> convert files into certain format.  I simply retrieve
> them from clients' machine and store them into a
> database.  Later on, clients can ask to view those
> files in their original format.
> 
> What appears in the text field:
> 
>     <input type="file" name="filename">
> 
> will be a file name. How do I get both the file name
> and the content of that file to be saved in the
> database?
> 
> _______________________________
> Do you Yahoo!?
> Declare Yourself - Register online to vote today!
> http://vote.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How To Upload Files from Clients' Machine?

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
Rather than reply to you here, I've added a page to the wiki...

   http://wiki.apache.org/struts/StrutsFileUpload

Niall


----- Original Message ----- 
From: "Caroline Jen" <ji...@yahoo.com>
To: <st...@jakarta.apache.org>
Sent: Monday, October 04, 2004 9:50 PM
Subject: How To Upload Files from Clients' Machine?


> In my JSP I have this:
> 
> code:
> -------------------------------------------------------
> 
>      <input type="file" name="filename">
> 
> -------------------------------------------------------
> 
> for visitors of the web page to browse their PCs'
> directories to select a file to upload (when the
> Submit button is clicked).  The files can be .doc,
> .txt, .pdf, .jpg, ..., etc.  However, I do not have to
> convert files into certain format.  I simply retrieve
> them from clients' machine and store them into a
> database.  Later on, clients can ask to view those
> files in their original format.
> 
> What appears in the text field:
> 
>     <input type="file" name="filename">
> 
> will be a file name. How do I get both the file name
> and the content of that file to be saved in the
> database? 
> 
> 
> 
> _______________________________
> Do you Yahoo!?
> Declare Yourself - Register online to vote today!
> http://vote.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org