How can PHP be used to display only specific file types, such as JPEGs, in the file selection dialog of a form?

To display only specific file types, such as JPEGs, in the file selection dialog of a form, you can use the 'accept' attribute in the input element of the form. This attribute specifies the types of files that the server accepts. In PHP, you can set the 'accept' attribute value dynamically based on the file types you want to allow.

<form action="upload.php" method="post" enctype="multipart/form-data">
    <input type="file" name="file" accept=".jpg, .jpeg">
    <input type="submit" value="Upload">
</form>