What potential pitfalls should be avoided when changing directory paths in PHP scripts for file uploads?

When changing directory paths in PHP scripts for file uploads, one potential pitfall to avoid is using relative paths that may not resolve correctly. It is recommended to use absolute paths to ensure the script can locate the correct directory consistently. Additionally, make sure the directory has the necessary permissions set to allow file uploads.

// Incorrect way using relative path
$uploadDir = 'uploads/';

// Correct way using absolute path
$uploadDir = '/var/www/html/uploads/';