HTML Form Enctype (x-www-form-urlencoded / form-data / text-plain)


  1. 說明
  2. 參考資料

筆記 HTML From 上傳資料上 Enctype 的差別。

logo

說明

Default application/x-www-form-urlencoded

純粹表單資料的時候 GET / POST 使用。

相當於 PostMan 的 x-www-form-urlencoded

multipart/form-data

將資料以 Binary 的方式由 Client 傳送至 Web Server,如果是要上傳檔案,必須要使用此 Enctype,可以兼容純粹表單的資料。

相當於 PostMan 的 form-data

text/plain

沒有人用,也不應該用?

相當於 PostMan 的 x-www-form-urlencoded

參考資料

一起理解 HTML 當中的 form-data | Kalan.dev

form 標籤與 FormData 的應用 | Kalan.dev

Using files from web applications | MDN