# open

## Description

To open any file with a the available local external mobile application available.

## Input / Parameter

| Name  | Description                                                | Input Type | Default | Options | Required |
| ----- | ---------------------------------------------------------- | ---------- | ------- | ------- | -------- |
| file  | The full file path of the file to be opened.               | Text       | -       | -       | Yes      |
| extra | Passed value so that it can be access by extra type value. | Any        | -       | -       | No       |

## Output

N/A

## Callback

### callback

The action performed if this function runs successfully.

| Description             | Output Type |
| ----------------------- | ----------- |
| Successful text massage | Text        |

### errorCallback

The action performed if this function does not run successfully.

| Description               | Output Type |
| ------------------------- | ----------- |
| Returns an error message. | Text        |

## Example

In this example, we will open a file that we chose from a file explorer app using a `fileChooser` function.

```js
Note: This example will only work if the user has a file on their device with the suitable app to open the file.
```

### Steps

1. Drag a button component to a page in the mobile designer, select the component and on the event `press` drag the `fileChooser` function to the event flow.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-c121bb9a9d570b46c5477b61be4ba5b35dac5da0%2Fopen-step-1.png?alt=media)
2. Inside the `fileChooser` function `yes` callback add the `open` function and fill in the parameter with `input` as the param type for `file`.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-67ffd8d63f7c66f5df5f743965ba84e1287cf99f%2Fopen-step-2.png?alt=media)

### Result

1. Open the installed app on a device and press the button, it should open up the file explorer app so we can choose from there.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-4325a2f2711376f46c9b722dd42f02edff3b4ad8%2Fopen-result-1.png?alt=media)
2. If the file and the suitable apps for opening that file exists, user should be able to see the popup where they can choose which app that they want to use for opening the file. Note: If there's only one app in the user device that's suitable for opening the file or the user had chosen a default app for opening that file type, it will automatically open that app without showing the app chooser popup.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-4c04d8b39bba364b1f194050f13f7753ed1aec5a%2Fopen-result-2.png?alt=media)
3. Check the file content using previously selected suitable app.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-940221da1e4000b3d3e4ceb7d7c343b1cf678df4%2Fopen-result-3.png?alt=media)

## Links

### Related Information

See also:

* Functions
  * [fileChooser](https://docs.emobiq.com/emobiq-client/006-actions-and-visual-logic/action-reference/cordova/device/filechooser)
