Skip to main content
Returns the path to a temporary file containing the contents of an uploaded file.

Signature

sqlpage.uploaded_file_path(field_name TEXT) -> TEXT

Parameters

field_name
TEXT
required
Name of the file input field in the form

Return Value

return
TEXT
Path to the temporary uploaded file, or NULL if no file was uploaded

Description

The uploaded_file_path() function returns the path to a temporary file where the uploaded content is stored. This file is automatically deleted after the request completes, so you must process or persist it during the request.

Examples

Store as Data URL

Read and store file as data URL in database:
INSERT INTO images (title, data)
VALUES (
    :title,
    sqlpage.read_file_as_data_url(sqlpage.uploaded_file_path('image'))
);

Store as Text

Read uploaded text file:
INSERT INTO documents (filename, content)
VALUES (
    sqlpage.uploaded_file_name('textfile'),
    sqlpage.read_file_as_text(sqlpage.uploaded_file_path('textfile'))
);

Save to Permanent Location

Use with persist_uploaded_file():
SET permanent_path = sqlpage.persist_uploaded_file('document', 'uploads', 'pdf,docx');

INSERT INTO files (path, uploaded_at)
VALUES ($permanent_path, CURRENT_TIMESTAMP);

Build docs developers (and LLMs) love