CURL.OpenInputFile
------------------

Opens file for reading data needed for upload, email sending or 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.OpenInputFile"; curl; Path { ; Offset; Length } ) 

**MBS**( **"CURL.OpenInputFile";** /\* Opens file for reading data needed for upload, email sending or HTTP Post. \*/  
**$curl**; /\* The CURL session handle. \*/   
**$Path**; /\* Native file path.e.g. "C:\\Documents\\Test.Txt" \*/   
**$Offset**; /\* Optional; Offset where to start reading relative to file start.e.g. 1024\*1024 \*/   
**$Length**) /\* Optional; Size of data to read from file.e.g. 1024\*1024\*10 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| curl | The CURL session handle. | $curl |  |
| Path | Native file path. | "C:\\Documents\\Test.Txt" |  |
| Offset | Offset where to start reading relative to file start. | 1024\*1024 | Optional      Added in version **8.4**. |
| Length | Size of data to read from file. | 1024\*1024\*10 | Optional      Added in version **8.4**. |

### Result

Returns "OK" on success or error message.

### Description

Opens file for reading data needed for upload, email sending or HTTP Post.  
If you set input file, the data from CURL.SetInput\* functions is ignored.  
Do not call this method while a transfer is running.  
  
If you have data in container, please check [CURL.SetInputFile](CURLSetInputFile.md).  
You may need to use [CURL.SetOptionUpload](CURLSetOptionUpload.md) to make it an upload for FTP/SFTP.  
  
If you specify offset or length, we only read that part of the file in memory.  
Otherwise we stream from the file on request.  
  
If you get an upload with 0 bytes length, it is quite likely, that this function couldn't open the file due to an invalid path or insufficient permissions.  
  
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

Set input from file on disk:

 Set Variable \[ $result ; Value: MBS ( "CURL.OpenInputFile"; $curl ; "/Users/cs/Desktop/test.zip" ) \]  
Upload file via FTP:

 Set Variable \[$curl ; Value:MBS ("[CURL.New](CURLNew.md)")\]  
  
\# FTP URL with destination file name:   
Set Variable \[$result ; Value: MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)" ; $curl ; "ftp://12.34 .56.78 /AZ1677ZZ.jpg")\]  
Set Variable \[$result ; Value: MBS ("[CURL.SetOptionUpload](CURLSetOptionUpload.md)" ; $curl ; 1)\]  
Set Variable \[$result ; Value: MBS ("[CURL.SetOptionPassword](CURLSetOptionPassword.md)" ; $curl ; "xxx" )\]  
Set Variable \[$result ; Value: MBS ("[CURL.SetOptionUserName](CURLSetOptionUserName.md)" ; $curl ; "yyy" )\]  
  
\# Pick file from desktop:   
Set Variable \[$Desktop ; Value: MBS ("[Folders.UserDesktop](FoldersUserDesktop.md)")\]  
Set Variable \[$Path ; Value: MBS ("[Path.AddPathComponent](PathAddPathComponent.md)"; $desktop ; "AZ1677ZZ.jpg")\]  
Set Variable \[$result ; Value: MBS ( "CURL.OpenInputFile" ; $curl ;$path )\]  
  
\# Pick file from container:   
// Set Variable \[$result ; Value: MBS ( "[CURL.SetInputFile](CURLSetInputFile.md)" ; $curl ; Test::ImageFileContainer )\]  
  
\# Upload file   
Set Field \[Test::PerformResult ; MBS ( "[CURL.Perform](CURLPerform.md)" ; $curl )\]  
Set Field \[Test::DebugMessages ; MBS ( "[CURL.GetDebugMessages](CURLGetDebugMessages.md)" ; $curl )\]  
Set Variable \[$result ; Value:MBS ( "[CURL.Release](CURLRelease.md)" ; $curl )\]  
### See also

- [CURL.CloseInputFile](CURLCloseInputFile.md)
- [CURL.SetOptionPostFields](CURLSetOptionPostFields.md)
- [CURL.SetOptionSSHPrivateKeyfile](CURLSetOptionSSHPrivateKeyfile.md)
- [CURL.SetOptionSSHPublicKeyfile](CURLSetOptionSSHPublicKeyfile.md)
- [CURL.SetOptionUpload](CURLSetOptionUpload.md)
- [CURL.SetOptionUserName](CURLSetOptionUserName.md)
- [Folders.UserDesktop](FoldersUserDesktop.md)
- [Hash.Digest](HashDigest.md)
- [Path.AddPathComponent](PathAddPathComponent.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)

### Release notes

- **Version 15.4**
    - Fixed [CURL.OpenInputFile](https://www.mbsplugins.eu/CURLOpenInputFile.shtml) to work for files over 4 GB in size to read chunks.
- **Version 12.1**
    - Fixed [CURL.OpenInputFile](https://www.mbsplugins.eu/CURLOpenInputFile.shtml) to stream files over 1 GB again.
- **Version 8.4**
    - Added new parameters for [CURL.OpenInputFile](http://www.mbsplugins.eu/CURLOpenInputFile.shtml) to load files in chunks.

### Example Databases

- [CURL/Amazon S3/Amazon S3 Upload File](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Amazon%20S3/Amazon%20S3%20Upload%20File.shtml#5ScriptAnchor_)
- [CURL/CURL Custom Function](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/CURL%20Custom%20Function.shtml#4CustomFunctionAnchor_)
- [CURL/FTP/CURL FTP Upload File](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/FTP/CURL%20FTP%20Upload%20File.shtml#2ScriptAnchor_)
- [CURL/FTP/CURL FTP Upload from file with Progress](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/FTP/CURL%20FTP%20Upload%20from%20file%20with%20Progress.shtml#2ScriptAnchor_)
- [CURL/SFTP/CURL sFTP Upload File](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/SFTP/CURL%20sFTP%20Upload%20File.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 15.4pr1](https://www.mbsplugins.de/archive/2025-08-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [CURL Custom Function](https://www.mbsplugins.de/archive/2022-12-12/CURL_Custom_Function/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 12.1pr7](https://www.mbsplugins.de/archive/2022-03-10/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [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)
- [Comparing Base Elements Plugin to MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2017-10-24/Comparing_Base_Elements_Plugin/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 4.2pr1](https://www.mbsplugins.de/archive/2014-04-02/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 3.3pr1](https://www.mbsplugins.de/archive/2013-05-24/MBS_Filemaker_Plugin_version_3/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 2.6pr4](https://www.mbsplugins.de/archive/2012-02-17/MBS_Filemaker_Plugin_version_2/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 25th February 2026

  
[CURL.NumberOfRunningTransfers](CURLNumberOfRunningTransfers.md) - [CURL.Options](CURLOptions.md)

[HTML Version](CURLOpenInputFile.shtml)