What are the implications of using relative paths versus absolute paths in PHP file uploads?

When uploading files in PHP, using relative paths can lead to issues with file paths not being resolved correctly, especially when the script is included in different directories. Absolute paths provide a fixed reference point and ensure that the file paths are always resolved correctly regardless of the script's location.

// Using absolute path for file upload
$uploadDir = '/var/www/html/uploads/';
$uploadFile = $uploadDir . basename($_FILES['userfile']['name']);

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile)) {
    echo "File is valid, and was successfully uploaded.\n";
} else {
    echo "Possible file upload attack!\n";
}