Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>Example implementation for SWFUpload, jQuery, JSP, Java and Spring</h1> <h2>First the jsp:</h2> <pre><code>&lt;%@ page language="java" pageEncoding="UTF-8" %&gt; &lt;head&gt; &lt;script type="text/javascript" src="&lt;c:url value="/public/js/swfupload/swfupload.js"/&gt;"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="&lt;c:url value="/public/js/jquery-plugins/ jquery.swfupload.js"/&gt;"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(function(){ $('.swfupload-control').swfupload({ // Backend Settings upload_url: "&lt;c:url value="/upload;jsessionid=${pageContext.session.id}"/&gt;", // Relative to the SWF file (or you can use absolute paths) // Flash Settings flash_url : "&lt;c:url value="/public/js/swfupload/swfupload.swf"/&gt;", //IMPORTANT: you need to set file_post_name otherwise flash sets it as Filedata, which does not conform to bean naming conventions. file_post_name: "file", // File Upload Settings file_size_limit : "102400", // 100MB file_types : "*.*", file_types_description : "All Files", file_upload_limit : "10", file_queue_limit : "0", // Button Settings button_image_url : "&lt;c:url value="/public/js/swfupload/XPButtonUploadText_61x22.png"/&gt;", // Relative to the SWF file button_placeholder_id : "spanButtonPlaceholder", button_width: 61, button_height: 22 }); // assign our event handlers $('.swfupload-control') .bind('fileQueued', function(event, file){ // start the upload once a file is queued $(this).swfupload('startUpload'); }) .bind('uploadComplete', function(event, file){ alert('Upload completed - '+file.name+'!'); // start the upload (if more queued) once an upload is complete $(this).swfupload('startUpload'); }); }); &lt;/script&gt; &lt;head&gt; &lt;body&gt; &lt;div id="file_upload"&gt;&lt;/div&gt; &lt;div class="swfupload-control"&gt; &lt;span id="spanButtonPlaceholder"&gt;&lt;/span&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <h2>Controller:</h2> <pre><code>@Controller public class UploadController { Logger logger = LoggerFactory.getLogger(this.getClass()); @RequestMapping(value="/upload", method=RequestMethod.POST) public String addMultiple( final HttpServletRequest request , final HttpServletResponse response , @RequestParam("file") MultipartFile file //NOTE: `@RequestParam("file")` matches `file_post_name: "file"` ){ logger.debug(uploadedFile.getOriginalFilename()); } } </code></pre> <p>Also, make sure you've got this in your configs:</p> <pre><code>&lt;bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt; &lt;/bean&gt; </code></pre> <p>If you are not using spring you might be able to cast the HttpServeletRequest as a MultiPartRequestWrapper use:</p> <pre><code>File[] files = ((MultiPartRequestWrapper)request).getFiles("Filedata"); </code></pre> <p>This solution doesn't require COS (Com O'Reilly Servlet). Instead it just uses the more common javax.servlet.http.HttpServletRequest</p> <p>Sources (stackoverflow wouldnt let me post links):</p> <ol> <li>swfupload.org/forum/generaldiscussion/1087</li> <li>demo.swfupload.org/Documentation/#setFilePostName</li> <li>blogs.bigfish.tv/adam/2009/06/14/swfupload-jquery-plugin/</li> <li>webdeveloperplus.com/jquery/multiple-file-upload-with-progress-bar-using-jquery/ (prettier implemenation of jquery uploader)</li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload