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
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
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
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_idstring required
The unique identifier of the browser context (e.g., 'ctx_000001')selectorstring required
CSS selector for the file input element (e.g., 'input[type="file"]', '#file-upload')file_pathsstring 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>
}