Skip to content

ValueError: Path cannot be empty in file_put_contents() #480

@patricksdd

Description

@patricksdd

The problem occurs here:

if (function_exists('sys_get_temp_dir')) {
$file = tempnam(sys_get_temp_dir(), "");
} else {
$file = tempnam("/tmp", "");
}
file_put_contents($file, $raw_data);

tempnam() can return false, which leads to file_put_contents() throwing ValueError: Path cannot be empty on PHP 8+.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions