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>
Keywords
Related Questions
- What are common issues faced when trying to establish LDAP authentication in PHP?
- What potential security risks are associated with the provided PHP script for handling form submissions?
- In the provided code examples, what are some potential pitfalls or vulnerabilities that could arise when handling user input in SQL queries?