java - How to detect if a form input element of type file is empty -


I have some code that reads the file through a file type file type

 < Code> & lt; Input type = "file" ... />  

Instead of uploading a URL to a file, rather than uploading it, I want to give another option because many people are already online.

How can I find this field is empty on server side? I am using Apache Commands FileUpload

  FileItemStream item = iter.next (); Name = item.getFieldName (); Section = item OpenStream (); If (item.isFormField ()) {if (item.toString ()! = "") {....  

I have to find out that when items is empty The above code does not work, nor does it use:

  if (item angle (empty)) {....  < / P> 

You can not call item.equals (null) when the item is zero is. You have to test it like this:

  if (item == empty) {...}  

Comments