How can PHP handle different file storage locations based on user input?

To handle different file storage locations based on user input in PHP, you can use conditional statements to determine the user input and then set the file storage location accordingly. This can be achieved by using an if-else statement or a switch statement to check the user input and assign the appropriate file storage location.

$user_input = $_POST['storage_location'];

if ($user_input == 'location1') {
    $file_storage_location = '/path/to/location1/';
} elseif ($user_input == 'location2') {
    $file_storage_location = '/path/to/location2/';
} else {
    $file_storage_location = '/default/path/';
}

// Use $file_storage_location variable to store files based on user input