FileImporter fails when a path is not entered

Permalink
Hi,

I have been following this page to add in a file submission field into a form:
https://www.concrete5.org/community/forums/customizing_c5/file-uploa...

My code works fine when there is a file selected. However, when there is no file selected, the call to create a new FileImporter() object fails.

Loader::library("file/importer"); // this works
$fi = new FileImporter();  // this fails


The deal is, the submit button is at the bottom of my form, and the file attachment is optional. So I need this to work when a file is not attached. I should be able to do an if statement before the $fi statement, but I'm not sure what that might be.

Help please!

pgkehle