This is an automated email from the ASF dual-hosted git repository.
git-site-role pushed a commit to branch asf-staging
in repository https://gitbox.apache.org/repos/asf/struts-site.git
The following commit(s) were added to refs/heads/asf-staging by this push:
new c0463a97e Updates stage by Jenkins
c0463a97e is described below
commit c0463a97e3f60d7ef7c164e2ec2b1c2ce1298b2b
Author: jenkins <[email protected]>
AuthorDate: Wed Mar 8 21:35:18 2023 +0000
Updates stage by Jenkins
---
content/core-developers/file-upload.html | 104 +++++++------------------------
1 file changed, 21 insertions(+), 83 deletions(-)
diff --git a/content/core-developers/file-upload.html
b/content/core-developers/file-upload.html
index a05500bff..ede426e0d 100644
--- a/content/core-developers/file-upload.html
+++ b/content/core-developers/file-upload.html
@@ -132,11 +132,7 @@
<h1 class="no_toc" id="file-upload">File Upload</h1>
<ul id="markdown-toc">
- <li><a href="#dependencies" id="markdown-toc-dependencies">Dependencies</a>
<ul>
- <li><a href="#struts-20x-file-upload-dependencies"
id="markdown-toc-struts-20x-file-upload-dependencies">Struts 2.0.x File Upload
Dependencies</a></li>
- <li><a href="#struts-21x-file-upload-dependencies"
id="markdown-toc-struts-21x-file-upload-dependencies">Struts 2.1.x File Upload
Dependencies</a></li>
- </ul>
- </li>
+ <li><a href="#dependencies"
id="markdown-toc-dependencies">Dependencies</a></li>
<li><a href="#basic-usage" id="markdown-toc-basic-usage">Basic Usage</a>
<ul>
<li><a href="#example-action-mapping"
id="markdown-toc-example-action-mapping">Example action mapping:</a></li>
<li><a href="#example-jsp-form-tags"
id="markdown-toc-example-jsp-form-tags">Example JSP form tags:</a></li>
@@ -161,8 +157,7 @@
</li>
</ul>
-<p>The Struts 2 framework provides built-in support for processing file
uploads that conform
-to <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>,
+<p>The Struts 2 framework provides built-in support for processing file
uploads that conform to <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC
1867</a>,
“Form-based File Upload in HTML”. When correctly configured the framework will
pass uploaded file(s) into your Action
class. Support for individual and multiple file uploads are provided. When a
file is uploaded it will typically be
stored in a temporary directory. Uploaded files should be processed or moved
by your Action class to ensure the data is
@@ -171,71 +166,13 @@ than the temporary directory and the directories that
belong to your web applica
<h2 id="dependencies">Dependencies</h2>
-<p>The Struts 2 framework leverages add-on libraries to handle the parsing of
uploaded files. These libraries are not
-included in the Struts distribution, you must add them into your project. The
libraries needed are:</p>
-
-<table>
- <thead>
- <tr>
- <th>Library</th>
- <th>URL</th>
- <th>Struts 2.0.x</th>
- <th>Struts 2.1.x</th>
- <th>Struts 2.5.x</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>Commons-FileUpload</td>
- <td><a
href="http://commons.apache.org/fileupload/">http://commons.apache.org/fileupload/</a></td>
- <td>1.1.1</td>
- <td>1.2.1</td>
- <td>1.3.2</td>
- </tr>
- <tr>
- <td>Commons-IO</td>
- <td><a
href="http://commons.apache.org/io/">http://commons.apache.org/io/</a></td>
- <td>1.0</td>
- <td>1.3.2</td>
- <td>2.4</td>
- </tr>
- </tbody>
-</table>
-
-<p>If you are using Maven then you can add these libraries as dependencies in
your project’s pom.xml.</p>
-
-<h3 id="struts-20x-file-upload-dependencies">Struts 2.0.x File Upload
Dependencies</h3>
-
-<div class="language-xml highlighter-rouge"><div class="highlight"><pre
class="highlight"><code><span class="nt"><dependency></span>
- <span class="nt"><groupId></span>commons-fileupload<span
class="nt"></groupId></span>
- <span class="nt"><artifactId></span>commons-fileupload<span
class="nt"></artifactId></span>
- <span class="nt"><version></span>1.1.1<span
class="nt"></version></span>
-<span class="nt"></dependency></span>
-<span class="nt"><dependency></span>
- <span class="nt"><groupId></span>commons-io<span
class="nt"></groupId></span>
- <span class="nt"><artifactId></span>commons-io<span
class="nt"></artifactId></span>
- <span class="nt"><version></span>1.0<span
class="nt"></version></span>
-<span class="nt"></dependency></span>
-</code></pre></div></div>
-
-<h3 id="struts-21x-file-upload-dependencies">Struts 2.1.x File Upload
Dependencies</h3>
-
-<div class="language-xml highlighter-rouge"><div class="highlight"><pre
class="highlight"><code><span class="nt"><dependency></span>
- <span class="nt"><groupId></span>commons-fileupload<span
class="nt"></groupId></span>
- <span class="nt"><artifactId></span>commons-fileupload<span
class="nt"></artifactId></span>
- <span class="nt"><version></span>1.2.1<span
class="nt"></version></span>
-<span class="nt"></dependency></span>
-<span class="nt"><dependency></span>
- <span class="nt"><groupId></span>commons-io<span
class="nt"></groupId></span>
- <span class="nt"><artifactId></span>commons-io<span
class="nt"></artifactId></span>
- <span class="nt"><version></span>1.3.2<span
class="nt"></version></span>
-<span class="nt"></dependency></span>
-</code></pre></div></div>
+<p>The Struts 2 framework leverages the Commons FileUpload library as a based
library to support file upload in the framework.
+The library is included in a base Struts 2 distribution.</p>
<h2 id="basic-usage">Basic Usage</h2>
<p>The <code class="language-plaintext
highlighter-rouge">org.apache.struts2.interceptor.FileUploadInterceptor</code>
class is included as part of the <code class="language-plaintext
highlighter-rouge">defaultStack</code>. As long as
-the required libraries are added to your project you will be able to take
advantage of of the Struts 2 fileUpload
+the required libraries are added to your project you will be able to take
advantage of the Struts 2 file upload
capability. Configure an Action mapping for your Action class as you typically
would.</p>
<h3 id="example-action-mapping">Example action mapping:</h3>
@@ -247,9 +184,10 @@ capability. Configure an Action mapping for your Action
class as you typically w
</code></pre></div></div>
<p>A form must be create with a form field of type file, <code
class="language-plaintext highlighter-rouge"><INPUT type="file"
name="upload"></code>. The form used to upload the
-file must have its encoding type set to <code class="language-plaintext
highlighter-rouge">multipart/form-data</code>
-, <code class="language-plaintext highlighter-rouge"><form
action="doUpload" enctype="multipart/form-data" method="post"></code>. The
standard procedure for adding these
-elements is by using the Struts 2 tag libraries as shown in the following
example:</p>
+file must have its encoding type set
+to <code class="language-plaintext
highlighter-rouge">multipart/form-data</code>, <code class="language-plaintext
highlighter-rouge"><form action="doUpload" enctype="multipart/form-data"
method="post"></code>.
+The standard procedure for adding these elements is by using the Struts 2 tag
libraries as shown in the following
+example:</p>
<h3 id="example-jsp-form-tags">Example JSP form tags:</h3>
@@ -335,10 +273,10 @@ see <code class="language-plaintext
highlighter-rouge">struts-fileupload.xml</co
<p><code class="language-plaintext
highlighter-rouge">multipleUploadUsingArray.jsp</code> Notice all file input
types have the same name.</p>
<div class="language-html highlighter-rouge"><div class="highlight"><pre
class="highlight"><code><span class="nt"><s:form</span> <span
class="na">action=</span><span class="s">"doMultipleUploadUsingArray"</span>
<span class="na">method=</span><span class="s">"POST"</span> <span
class="na">enctype=</span><span class="s">"multipart/form-data"</span><span
class="nt">></span>
- <span class="nt"><s:file</span> <span class="na">label=</span><span
class="s">"File (1)"</span> <span class="na">name=</span><span
class="s">"upload"</span> <span class="nt">/></span>
- <span class="nt"><s:file</span> <span class="na">label=</span><span
class="s">"File (2)"</span> <span class="na">name=</span><span
class="s">"upload"</span> <span class="nt">/></span>
- <span class="nt"><s:file</span> <span class="na">label=</span><span
class="s">"FIle (3)"</span> <span class="na">name=</span><span
class="s">"upload"</span> <span class="nt">/></span>
- <span class="nt"><s:submit</span> <span class="na">cssClass=</span><span
class="s">"btn btn-primary"</span><span class="nt">/></span>
+ <span class="nt"><s:file</span> <span class="na">label=</span><span
class="s">"File (1)"</span> <span class="na">name=</span><span
class="s">"upload"</span><span class="nt">/></span>
+ <span class="nt"><s:file</span> <span class="na">label=</span><span
class="s">"File (2)"</span> <span class="na">name=</span><span
class="s">"upload"</span><span class="nt">/></span>
+ <span class="nt"><s:file</span> <span class="na">label=</span><span
class="s">"FIle (3)"</span> <span class="na">name=</span><span
class="s">"upload"</span><span class="nt">/></span>
+ <span class="nt"><s:submit</span> <span
class="na">cssClass=</span><span class="s">"btn btn-primary"</span><span
class="nt">/></span>
<span class="nt"></s:form></span>
</code></pre></div></div>
@@ -398,10 +336,10 @@ see <code class="language-plaintext
highlighter-rouge">struts-fileupload.xml</co
<p><code class="language-plaintext
highlighter-rouge">multipleUploadUsingList.jsp</code> Notice all file input
types have the same name.</p>
<div class="language-html highlighter-rouge"><div class="highlight"><pre
class="highlight"><code><span class="nt"><s:form</span> <span
class="na">action=</span><span class="s">"doMultipleUploadUsingList"</span>
<span class="na">method=</span><span class="s">"POST"</span> <span
class="na">enctype=</span><span class="s">"multipart/form-data"</span><span
class="nt">></span>
- <span class="nt"><s:file</span> <span class="na">label=</span><span
class="s">"File (1)"</span> <span class="na">name=</span><span
class="s">"upload"</span> <span class="nt">/></span>
- <span class="nt"><s:file</span> <span class="na">label=</span><span
class="s">"File (2)"</span> <span class="na">name=</span><span
class="s">"upload"</span> <span class="nt">/></span>
- <span class="nt"><s:file</span> <span class="na">label=</span><span
class="s">"FIle (3)"</span> <span class="na">name=</span><span
class="s">"upload"</span> <span class="nt">/></span>
- <span class="nt"><s:submit</span> <span class="na">cssClass=</span><span
class="s">"btn btn-primary"</span><span class="nt">/></span>
+ <span class="nt"><s:file</span> <span class="na">label=</span><span
class="s">"File (1)"</span> <span class="na">name=</span><span
class="s">"upload"</span><span class="nt">/></span>
+ <span class="nt"><s:file</span> <span class="na">label=</span><span
class="s">"File (2)"</span> <span class="na">name=</span><span
class="s">"upload"</span><span class="nt">/></span>
+ <span class="nt"><s:file</span> <span class="na">label=</span><span
class="s">"FIle (3)"</span> <span class="na">name=</span><span
class="s">"upload"</span><span class="nt">/></span>
+ <span class="nt"><s:submit</span> <span
class="na">cssClass=</span><span class="s">"btn btn-primary"</span><span
class="nt">/></span>
<span class="nt"></s:form></span>
</code></pre></div></div>
@@ -468,7 +406,7 @@ struts.multipart.maxFiles=256
</code></pre></div></div>
<blockquote>
- <p>Please remember that the <code class="language-plaintext
highlighter-rouge">struts.multipart.maxSize</code> is the size limit of the
whole request, which means when you’re
+ <p>Please remember that the <code class="language-plaintext
highlighter-rouge">struts.multipart.maxSize</code> is the size limit of the
whole request, which means when you’re
uploading multiple files, the sum of their size must be below the <code
class="language-plaintext
highlighter-rouge">struts.multipart.maxSize</code>!</p>
</blockquote>
@@ -523,13 +461,12 @@ receive a file that is too large. Notice the locations of
both settings in the f
<h3 id="files-number-limit">Files Number Limit</h3>
-<p>Since Struts 6.2.0 a new option was added, which uses Commons FileUpload
feature to limit how many files can be uploaded
+<p>Since Struts 6.1.2/6.2.0 a new option was added, which uses Commons
FileUpload feature to limit how many files can be uploaded
at once, in one request. This option requires to use Commons FileUpload ver.
1.5 at least and by default is set to <strong>256</strong>.
To change this value define a constant in <code class="language-plaintext
highlighter-rouge">struts.xml</code> as follows:</p>
<div class="language-xml highlighter-rouge"><div class="highlight"><pre
class="highlight"><code><span class="nt"><struts></span>
<span class="nt"><constant</span> <span class="na">name=</span><span
class="s">"struts.multipart.maxFiles"</span> <span
class="na">value=</span><span class="s">"500"</span><span
class="nt">/></span>
-
<span class="nt"></struts></span>
</code></pre></div></div>
@@ -635,7 +572,8 @@ follow:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre
class="highlight"><code>^multipart/form-data(?:\\s*;\\s*boundary=[0-9a-zA-Z'()+_,\\-./:=?]{1,70})?(?:\\s*;\\s*charset=[a-zA-Z\\-0-9]{3,14})?
</code></pre></div></div>
-<p>Please read <a
href="https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html">RFC1341</a> the
<strong>Multipart section</strong> for more details,
+<p>Please read <a
href="https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html">RFC1341</a> the
<strong>Multipart section</strong> for more
+details,
existing Struts <code class="language-plaintext
highlighter-rouge">Multipart</code> parsers support only <code
class="language-plaintext highlighter-rouge">multipart/form-data</code> content
type. This option is available since
Struts 2.3.11.</p>