What is the correct syntax for the enctype attribute in a form for file uploads in PHP?
When creating a form that allows file uploads in PHP, it is important to set the enctype attribute to "multipart/form-data". This attribute specifies how the form data should be encoded when submitting the form. Without setting this attribute correctly, the file upload functionality will not work as expected.
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" value="Upload">
</form>
Keywords
Related Questions
- What are the potential pitfalls of using outdated PHP functions like mysql_query?
- Are there any best practices for handling date and time conversions in PHP to avoid errors?
- How can the issue of images being displayed out of order (1, 10, 11, 12) instead of (1, 2, 3, ...) be resolved in the PHP script?