# browser\_upload\_file

## Browser Upload File

Upload files to a file input element. Programmatically sets the files on an input[type='file'] element. Supports multiple files if the input accepts them. File paths must be absolute paths on the server.

## Usage Example

### CURL

```bash
POST `/api/execute/browser_upload_file`

curl -X POST \
 -H "Authorization: Bearer <token>" \
 -H "Content-Type: application/json" \
 -d '{
"context_id": "ctx_000001",
"selector": "#element-id",
"file_paths": "<file_paths>"
}' \
http://localhost:8080/api/execute/browser_upload_file
```

### Python SDK

```python
import asyncio

from owl_browser import OwlBrowser, RemoteConfig

# Async usage
async with OwlBrowser(config) as browser:
    context = await browser.create_context()
    context_id = context["context_id"]
    await browser.upload_file(
        context_id=context_id,
        selector="#element-id",
        file_paths="value"
    )
```

### Node.js SDK

```javascript
import { OwlBrowser } from '@olib-ai/owl-browser-sdk';

// Async usage
const ctx = await browser.createContext();
const contextId = ctx.context_id;
await browser.uploadFile({
    context_id: contextId,
    selector: '#element-id',
    file_paths: 'value'
});
```

## Parameters

### Required

- `context_id` string required  
  The unique identifier of the browser context (e.g., 'ctx\_000001')
- `selector` string required  
  CSS selector for the file input element (e.g., 'input[type="file"]', '#file-upload')
- `file_paths` string required  
  Array of file paths to upload. Can be a JSON array string or actual array. For JSON input use server paths. For multipart upload, files are saved to temp paths automatically.

## Response

Returns a JSON object with the operation result.

```
{
  "success": true,
  "result": <value>
}
```
