How can PHP be used to restrict file uploads to only images in jpg format?

To restrict file uploads to only images in jpg format using PHP, you can check the file type of the uploaded file before allowing it to be saved on the server. This can be done by checking the MIME type of the file using the `$_FILES` superglobal array.

if ($_FILES['file']['type'] == 'image/jpeg') {
    // Process the file upload
    move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/' . $_FILES['file']['name']);
    echo 'File uploaded successfully.';
} else {
    echo 'Only JPG images are allowed.';
}