How can the user ensure that the uploaded file on Dropbox retains the .jpg extension?

When uploading a file to Dropbox, the user can ensure that the file retains the .jpg extension by explicitly setting the file name with the .jpg extension before uploading it. This can be done by checking the file type before uploading and appending the .jpg extension if it is not already present. This ensures that the file will be recognized as a JPG file even after being uploaded to Dropbox.

// Check the file type before uploading
$fileName = $_FILES['file']['name'];
$fileType = $_FILES['file']['type'];

// Append .jpg extension if not already present
if ($fileType != 'image/jpeg' && $fileType != 'image/jpg') {
    $fileName = pathinfo($fileName, PATHINFO_FILENAME) . '.jpg';
}

// Upload the file to Dropbox with the modified file name
// Your Dropbox upload code here