What is the maximum filename length allowed in Linux distributions like Debian for file uploads using PHP?

In Linux distributions like Debian, the maximum filename length allowed for file uploads using PHP is typically determined by the underlying file system. To ensure compatibility and prevent potential issues with long filenames, it is recommended to limit the filename length to a reasonable size before uploading the file.

// Limit the filename length before uploading
$filename = $_FILES['file']['name'];
$maxlength = 255; // Maximum filename length allowed
if (strlen($filename) > $maxlength) {
    $filename = substr($filename, 0, $maxlength);
}
move_uploaded_file($_FILES['file']['tmp_name'], '/path/to/uploaded/files/' . $filename);