1
如果使用enctype屬性(例如enctype = multipart/form-data)發佈HTML表單並將其提交給Express路由,如何從路由或中間件訪問該enctype值?我在Express 4.x上。NodeJS/Express:如何獲取提交表單的enctype?
如果使用enctype屬性(例如enctype = multipart/form-data)發佈HTML表單並將其提交給Express路由,如何從路由或中間件訪問該enctype值?我在Express 4.x上。NodeJS/Express:如何獲取提交表單的enctype?
當您在表單上設置enctype
屬性時,瀏覽器在請求(see this SO question for more details)中將其作爲content-type
發送。在Express中,您可以從請求對象訪問content-type
標題名稱,如下所示:req.headers['content-type']
。
我認爲它應該在標題中,以便檢查req.headers – Molda