# Optional Upload of Files

**URL:** <https://community.ofelia.com/t/optional-upload-of-files/7185>\
**Category:** Q&A\
**Created:** [4 April 2016 12:37 UTC](https://community.ofelia.com/t/optional-upload-of-files/7185 "2016-04-04T12:37:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![julia.sbarra](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@julia.sbarra](https://community.ofelia.com/u/julia.sbarra)\
**Post date:** [4 April 2016 12:37 UTC](https://community.ofelia.com/t/optional-upload-of-files/7185/1 "2016-04-04T12:37:48Z")

</div>

Hi! I am working with 7.1.2 Community Version.  
Is it possible to configure optional upload of files? In the example I followed to configure the upload of files the user must upload a file in order to submit the form. And the fact is that the user may not need to upload a file, that is why I need to change the configuration buy I don’t find how to do it.  
Thanks very much for your help!  
Best regards,

Julia.-

---

<div class="post-metadata">

**Author:** ![Sean\_McP](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/sean_mcp/32/932_2.png) [@Sean\_McP](https://community.ofelia.com/u/Sean_McP)\
**Post date:** [4 April 2016 13:24 UTC](https://community.ofelia.com/t/optional-upload-of-files/7185/2 "2016-04-04T13:24:58Z")

</div>

Have a look at this post:

[http://community.ofelia.com/questions-and-answers/does-anyone-know-or-trick-how-set-contract-type-file-null](http://community.ofelia.com/questions-and-answers/does-anyone-know-or-trick-how-set-contract-type-file-null)

Regards  
Seán

_PS: if this answers your question, please mark as resolved._

---

<div class="post-metadata">

**Author:** ![julia.sbarra](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@julia.sbarra](https://community.ofelia.com/u/julia.sbarra)\
**Post date:** [4 April 2016 16:30 UTC](https://community.ofelia.com/t/optional-upload-of-files/7185/3 "2016-04-04T16:30:13Z")

</div>

Thanks Sean!  
In my case I have to submit not only a file (which is optional) but other variables. I tried following that example but it does not work.  
I wonder, where I have to enter the following script?

import org.bonitasoft.engine.bpm.contract.FileInputValue  
import org.bonitasoft.engine.bpm.document.Document  
import org.bonitasoft.engine.bpm.document.DocumentValue

if(myDocumentContract != null) {  
return myDocumentContract  
} else {  
Document currentDocument = apiAccessor.processAPI.getLastDocument(processInstanceId, “myDocument”)

```
FileInputValue fileInputValue = new FileInputValue(currentDocument.contentFileName, apiAccessor.processAPI.getDocumentContent(currentDocument.contentStorageId))

return fileInputValue

```

}

I entered it, following the example, in “operations”, but have not positive results.  
Thanks very much!  
Best regards,

Julia.-
