File uploads always need multipart encoded forms

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the web-development category.

Last Updated: 2024-12-03

Any time you need to upload a file over HTTP forms, what else do you need to do?

Add the enctype to the form:

<form enctype="multipart/form-data">
</form>

This has to do with how the browser packages binary and form data for transmission over HTTP. By default only form data is sent, but if the form needs to support uploading a file, then the binary data must also be appended and separated from the form data.

Resources