Are there any specific PHP functions or libraries that can assist in managing uploaded images and their URLs on a website?

When managing uploaded images on a website, it is important to store the images in a secure directory on the server and generate unique URLs for each image to display them on the website. PHP provides functions and libraries that can assist in handling image uploads, storing them securely, and generating URLs for easy access.

<?php
// Handle image upload
if(isset($_FILES['image'])){
    $target_dir = "uploads/";
    $target_file = $target_dir . basename($_FILES["image"]["name"]);
    move_uploaded_file($_FILES["image"]["tmp_name"], $target_file);
    
    // Generate unique URL for the uploaded image
    $image_url = "https://example.com/" . $target_file;
    
    // Display the image on the website
    echo "<img src='$image_url' alt='Uploaded Image'>";
}
?>