What are some alternative methods or libraries for handling file uploads in PHP that could avoid potential FTP issues?

When dealing with file uploads in PHP, using alternative methods or libraries such as the Symfony HttpFoundation component can help avoid potential FTP issues. This component provides a more robust and secure way to handle file uploads, including handling file validation, renaming, and moving.

// Example using Symfony HttpFoundation component for handling file uploads
use Symfony\Component\HttpFoundation\File\UploadedFile;

// Get the uploaded file from the request
$file = $request->files->get('file');

// Validate the file
if ($file instanceof UploadedFile) {
    // Move the file to a secure location
    $file->move($directory, $filename);
} else {
    // Handle invalid file upload
}