What is a simple method to transfer an image from a local machine to a server in PHP?

To transfer an image from a local machine to a server in PHP, you can use the move_uploaded_file() function. This function moves an uploaded file to a new location. You need to specify the temporary location of the file on the server and the destination path where you want to move the file.

<?php
$uploadedFile = $_FILES['file']['tmp_name'];
$destination = 'uploads/' . $_FILES['file']['name'];

if (move_uploaded_file($uploadedFile, $destination)) {
    echo 'File uploaded successfully.';
} else {
    echo 'Failed to upload file.';
}
?>