CURL.FormAddKeyFile
-------------------

Add a section to a multipart/formdata HTTP POST.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [CURL](component_CURL.md) | [2.6](newinversion26.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "CURL.FormAddKeyFile"; curl; Name; Path { ; ContentType; ContentHeaders } ) 

**MBS**( **"CURL.FormAddKeyFile";** /\* Add a section to a multipart/formdata HTTP POST. \*/  
**$curl**; /\* The CURL session handle. \*/   
**$Name**; /\* The name of the form field.e.g. "city" \*/   
**$Path**; /\* Native file path.e.g. "/Users/cs/Desktop/test.txt" \*/   
**$ContentType**; /\* Optional; The content type for this file.e.g. "text/plain" \*/   
**$ContentHeaders**) /\* Optional; List of headers to include.e.g. "Content-Id: 12345" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| curl | The CURL session handle. | $curl |  |
| Name | The name of the form field. | "city" |  |
| Path | Native file path. | "/Users/cs/Desktop/test.txt" |  |
| ContentType | The content type for this file. | "text/plain" | Optional      Added in version **10.3**. |
| ContentHeaders | List of headers to include. | "Content-Id: 12345" | Optional      Added in version **10.3**. |

### Result

Returns "OK" or error code.

### Description

Add a section to a multipart/formdata HTTP POST.  
This adds a file with the given key name into the form.  
Please call [CURL.FormFinish](CURLFormFinish.md) after you added all your fields and before you call [CURL.Perform](CURLPerform.md).  
  
This function requires a native path. Use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use [FileDialog](component_FileDialog.md) functions.  
For Server be aware that server has limited permissions and may not be able to access all files on a computer.  
### Examples

Add image file to form:

 MBS ("CURL.FormAddKeyFile"; $curl ; "Attachment"; "/Users/cs/desktop/Paris.jpg")  
### See also

- [CURL.FormAddKeyFileContentType](CURLFormAddKeyFileContentType.md)
- [CURL.FormAddKeyText](CURLFormAddKeyText.md)
- [CURL.FormAddKeyValue](CURLFormAddKeyValue.md)
- [CURL.FormFinish](CURLFormFinish.md)
- [CURL.Perform](CURLPerform.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)

### Release notes

- **Version 10.3**
    - Added ContentType and ContentHeaders parameter for [CURL.FormAddKeyContainer](https://www.mbsplugins.eu/CURLFormAddKeyContainer.shtml), [CURL.FormAddKeyFile](https://www.mbsplugins.eu/CURLFormAddKeyFile.shtml), [CURL.FormAddKeyText](https://www.mbsplugins.eu/CURLFormAddKeyText.shtml) and [CURL.FormAddKeyValue](https://www.mbsplugins.eu/CURLFormAddKeyValue.shtml).

### Blog Entries

- [Translating Insert from URL options for CURL to MBS Plugin calls](https://www.mbsplugins.de/archive/2020-12-14/Translating_Insert_from_URL_op/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.3pr1](https://www.mbsplugins.de/archive/2020-06-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 2.6pr6](https://www.mbsplugins.de/archive/2012-03-12/MBS_Filemaker_Plugin_version_2/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 14th May 2020

  
[CURL.FormAddKeyContainerContentType](CURLFormAddKeyContainerContentType.md) - [CURL.FormAddKeyFileContentType](CURLFormAddKeyFileContentType.md)

[HTML Version](CURLFormAddKeyFile.shtml)