if(isset($_FILES['file'])) { if(hasFile($_FILES['file']['tmp_name'])) { echo "File has been uploaded."; } else { echo "File has not been uploaded."; } }
use Symfony\Component\HttpFoundation\File\UploadedFile; $file = new UploadedFile($_FILES['avatar']['tmp_name'], $_FILES['avatar']['name'], $_FILES['avatar']['type'], $_FILES['avatar']['size'], $_FILES['avatar']['error']); if ($file->isValid()) { if(hasFile($file->getPath())) { echo "File has been uploaded."; } else { echo "File has not been uploaded."; } }In this example, we use the Symfony package library to create an UploadedFile object from the files uploaded via the form submission. Then we use the hasFile function to validate if the file exists in the temporary folder. If it does, we display a message that the file has been uploaded. If not, we display a message that the file has not been uploaded.