Image and Binary File Conversion

DWR 3.0 features a new FileConverter that handles the following binary files:

In order for upload to work, commons-fileupload and commons-io are required on the classpath. See the commons-upload dependency chart for more information. DWR will give you the error message: "file uploads not supported" if this JAR file is missing.

Specifying a max upload size

If you would like to limit the maximum allowed size of file uploads we provide the "fileUploadMaxBytes" init-param on the DWR servlet. This parameter can be specified as follows:
     <init-param>
      <param-name>fileUploadMaxBytes</param-name>
      <param-value>5000</param-value>
     </init-param>

Plugging in a custom Upload implementation

The FileUpload implementation used by DWR is also pluggable. If you would like to write your own implementation simply implement org.directwebremoting.dwrp.FileUpload and use DWR's plug-in architecture to specify the implementation via an init-param on the DWR servlet.
    <init-param>
     <param-name>org.directwebremoting.dwrp.FileUpload</param-name>
     <param-value>your.package.YourFileUploadImpl</param-value>
    </init-param>

Examples in the DWR.war

The DWR war file contains an example of generating PDF files, as well as uploading and downloading images. Full source and explanations are included with these examples.