1.

How Can I Detect If An Optional File Has Been Uploaded?

Answer»

The receive() METHOD will return true for file elements that are not required. The reason is that you said “the file can be omitted, and that’s ok for me”. The receive() method will return false only in the event of a failure.

Still there are several ways to detect if a file has been uploaded or not:

  • Use isUploaded which RETURNS a boolean
  • Use getFileName which returns null in this case (NOTE that you MUST use the latest release for this behavior)
  • Use getFileInfo which will have an empty ‘file’ key and the flag ‘isUploaded’ set to false

The receive() method will return true for file elements that are not required. The reason is that you said “the file can be omitted, and that’s ok for me”. The receive() method will return false only in the event of a failure.

Still there are several ways to detect if a file has been uploaded or not:



Discussion

No Comment Found