title: Tomcat Liferay Small File Uploads (< 1kb)
body: <p>I am running into an issue with Tomcat Liferay file uploads.</p>
  
  <p>In the code I get an empty file size, causing Tomcat to return null when it tries to find the newly uploaded file in the Tomcat Temp folder.</p>
  
  <p>My code:</p>
  
  <pre><code>File[] files = uploadRequest.getFiles("fileupload");
  for(File f : files) {
      (f.length == 0) { /* This is always true (null file upload) */ }
      FileUtil.copyFile(f, newfile); // This throws a null pointer exception
  }
  
  // Also happens with any other attempts at getting the file from the form, like this (below). 
  // None of these work with files &lt; 1 kb
  FileItem[] fileitems = uploadRequest.getMultipartParameterMap().get("fileupload");
  </code></pre>
  
  <p>If the file is larger than 1kb, then it actually works. The real issue is that the above code errors when I actually try and actually move the file using FileUtil.copyFile() - it throws a null pointer exception saying the original file (which is supposed to be in the temp folder at this point), is null.</p>
  
  <p>Pretty confused at why this happens. Here is the HTML for this:</p>
  
  <pre><code>&lt;aui:form action="&lt;%=uploadFileURL%&gt;" enctype="multipart/form-data" method="POST"&gt;
      &lt;aui:input type="hidden" value="/" name="selected_dir_input"/&gt;
      &lt;b&gt;Selected Folder: &lt;/b&gt;
      &lt;span id="selected_folder"&gt;/Home/User/Desktop/Some_Selected_file.ext&lt;/span&gt;
      &lt;aui:input type="file" name="fileupload" multiple="true"/&gt;
      &lt;aui:button name="Upload" value="Upload" type="submit" /&gt;
  &lt;/aui:form&gt;
  </code></pre>
  
  <p>Thanks</p>