# Upload File

The Upload File control allows users to upload files to the server.

These files will be stored in a temporary location on the server for the duration of the user's session. Once the session ends, they are deleted. It is therefore important to write these files to a known location in order to access them at a later stage again. This can be done by looping over the files using a ForEach action inside of a script or eventhandler.

**When adding an Upload File control, do this:**

* Drag the *Upload File* control onto the canvas.
* Add a *Button* control and create a *click* event handler for the Button.
* Add a *ForEach* action to the event handler.
* Add to the *Loop* section of the *ForEach* action, the *WriteFile* operation from the *File Connector* and indicate the directory path for the uploaded file.
* Add the required processing to handle the uploaded file to the *Loop* section of the *ForEach* action.

***

**Please note:**\
Due to restriction of the browser, a file without an extension can only be downloaded and cannot be opened or viewed in a browser tab.

***

{% embed url="<https://www.youtube.com/embed/8WrHyuQuHwE?autoplay=1&rel=0&vq=1080>" %}
*Add an Upload File control*
{% endembed %}

***

### Properties

1. **Visible**

   Set to False if you don't want this control to render on the page and be visible to the user.

***

### Error Messages:

1. **File must be smaller than x MB**

   If this value has to be increased, change the maxRequestLength value in the web.config of the generated application. The maxRequestLength is specified in kilobytes and defaults to 4096 KB (4 MB). See [here](https://msdn.microsoft.com/en-us/library/system.web.configuration.httpruntimesection.maxrequestlength\(v=vs.110\).aspx) for more information on maxRequestLength.

   ```
   	<configuration>
   		<system.web>
   			<httpRuntime targetFramework="4.6" maxRequestLength="153600" />
   		</system.web>
   	</configuration>
   		
   ```
2. **Error**

   This could be caused by a number of reasons, of which one could be that the maxAllowedContentLength is not large enough. Increasing this value in the web.config of the generated application could resolve the issue. The maxAllowedContentLength is specified in bytes and defaults to 30000000 (28.6 MB). See [here](https://msdn.microsoft.com/en-us/library/ms689462\(v=vs.90\).aspx) for more information on maxAllowedContentLength.

   ```
   	<configuration>
   		<system.webServer>
   			<security>
   				<requestFiltering>
   					<requestLimits maxAllowedContentLength="30000000" />
   				</requestFiltering>
   			</security>
   		</system.webServer>
   	</configuration>
   		
   ```
