What potential issues can arise when uploading files to a web server using FTP, specifically in relation to file permissions and duplicate files?

Issue: When uploading files to a web server using FTP, potential issues can arise with file permissions and duplicate files. File permissions may not be set correctly, causing access issues for users. Duplicate files may also be created if the same file is uploaded multiple times, leading to confusion and wasted storage space. Solution: To address file permission issues, ensure that the correct permissions are set for uploaded files. To prevent duplicate files, you can check if a file with the same name already exists on the server before uploading.

// Set correct file permissions after uploading
ftp_chmod($ftp_connection, 0644, $remote_file);

// Check for duplicate files before uploading
if (!file_exists($remote_file)) {
    ftp_put($ftp_connection, $remote_file, $local_file, FTP_BINARY);
    echo "File uploaded successfully.";
} else {
    echo "File with the same name already exists.";
}