How to detect if a form input element of type file is empty
Posted
by Ankur
on Stack Overflow
See other posts from Stack Overflow
or by Ankur
Published on 2010-05-16T11:05:23Z
Indexed on
2010/05/16
11:10 UTC
Read the original article
Hit count: 186
I have some code which reads a file through a form field of type file
<input type="file" ... />
I want to give the user another option of providing a url to a file rather than having to upload it as many are already online.
How can I detect when this field is empty on the server side. I am using Apache Commons FileUpload
FileItemStream item = iter.next();
name = item.getFieldName();
stream = item.openStream();
if(!item.isFormField()){
if(item.toString()!=""){
....
I need to detect when item
is empty. The above code doesn't work, nor does using:
if(item.equals(null)){
....
© Stack Overflow or respective owner