FormData 인터페이스는 form 필드와 그 값을 나타내는 일련의 key/value 쌍을 쉽게 생성할 수 있는 방법을 제공합니다. 또한 XMLHttpRequest.send() 메서드를 사용하여 쉽게 전송할 수 있습니다. 인코딩 타입이 "multipart/form-data"로 설정된 경우, form에서 사용하는 것과 동일한 포맷을 사용해야 합니다.

간단한 GET 전송을 사용하는 경우에는 <form> 이 수행하는 방식으로 쿼리 매개 변수를 생성할 수 있습니다. 이 경우 URLSearchParams 생성자에 직접 전달할 수 있습니다.

FormData 를 구현하는 객체는 entries() 대신 for...of 구조를 직접 사용할 수 있습니다. for (var p of myFormData) 는 for (var p of myFormData.entries()) 와 같습니다.

주의: 이 기능은 Web Workers에서도 사용할 수 있습니다.

생성자

FormData()
새로운 FormData 객체를 생성합니다.

메소드

FormData.append()
FormData 객체안에 이미 키가 존재하면 그 키에 새로운 값을 추가하고, 키가 없으면 추가합니다.
FormData.delete()
FormData 객체로부터 키/밸류 쌍을 삭제합니다.
FormData.entries()
이 객체에 담긴 모든 키/밸류 쌍을 순회할 수 있는 iterator를 반환합니다.
FormData.get()
FormData 객체 내의 값들 중 주어진 키와 연관된 첫번째 값을 반환합니다.
FormData.getAll()
FormData 객체 내의 값들 중 주어진 키와 연관된 모든 값이 담긴 배열을 반환합니다.
FormData.has()
FormData 객체에 특정 키가 포함되어 있는지 여부를 나타내는 boolean 을 반환합니다.
FormData.keys()
이 객체에 담긴 모든 키/벨류 쌍들의 모든 키들을 순회 할 수 있는 iterator를 반환합니다.
FormData.set()
FormData 객체 내에 있는 기존 키에 새 값을 설정하거나, 존재하지 않을 경우 키/밸류 쌍을 추가합니다.
FormData.values()
이 객체에 포함된 모든 밸류를 통과하는 iterator를 반환합니다.

명세

Specification Status Comment
XMLHttpRequest
The definition of 'FormData' in that specification.
Living Standard FormData defined in XHR spec

브라우저 호환성

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
FormDataChrome Full support 7Edge Full support YesFirefox Full support 4
Notes
Full support 4
Notes
Notes Prior to Firefox 7, specifying a Blob as the data to append to the object, the filename reported in the Content-Disposition HTTP header was an empty string, resulting in errors on some servers. Starting with Firefox 7, the filename blob is sent.
IE Full support 10Opera Full support 12Safari Full support 5WebView Android Full support Yes
Notes
Full support Yes
Notes
Notes XHR in Android 4.0 sends empty content for FormData with blob.
Chrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 12Safari iOS Full support YesSamsung Internet Android Full support Yes
FormData() constructorChrome Full support 7Edge Full support YesFirefox Full support 4IE Full support 10Opera Full support 12Safari Full support 5WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android Full support 12Safari iOS ? Samsung Internet Android ?
appendChrome Full support 7Edge Full support 12Firefox Full support 4
Notes
Full support 4
Notes
Notes Prior to Firefox 7, specifying a Blob as the data to append to the object, the filename reported in the Content-Disposition HTTP header was an empty string, resulting in errors on some servers. Starting with Firefox 7, the filename blob is sent.
IE Full support 10
Notes
Full support 10
Notes
Notes With the "Include local directory pass when uploading files to a server" option enabled, IE will change the filename inside the Blob on the fly. To have direct control of the sent filename, the developer should send the filename as the third parameter value, i.e. formData.append(name, value, filename).
Opera Full support 12Safari Full support 5WebView Android Full support 3
Notes
Full support 3
Notes
Notes XHR in Android 4.0 sends empty content for FormData with blob.
Chrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4
Notes
Full support 4
Notes
Notes Prior to Firefox 7, specifying a Blob as the data to append to the object, the filename reported in the Content-Disposition HTTP header was an empty string, resulting in errors on some servers. Starting with Firefox 7, the filename blob is sent.
Opera Android Full support 12Safari iOS Full support YesSamsung Internet Android Full support Yes
deleteChrome Full support 50Edge Full support 18Firefox Full support 39IE No support NoOpera Full support YesSafari Full support 11WebView Android Full support YesChrome Android Full support 50Edge Mobile No support NoFirefox Android Full support YesOpera Android Full support YesSafari iOS No support NoSamsung Internet Android Full support Yes
getChrome Full support 50Edge Full support 18Firefox Full support 39IE No support NoOpera Full support YesSafari Full support 11WebView Android Full support YesChrome Android Full support 50Edge Mobile No support NoFirefox Android Full support YesOpera Android Full support YesSafari iOS No support NoSamsung Internet Android Full support Yes
getAllChrome Full support 50Edge Full support 18Firefox Full support 39IE No support NoOpera Full support YesSafari Full support 11WebView Android Full support YesChrome Android Full support 50Edge Mobile No support NoFirefox Android Full support YesOpera Android Full support YesSafari iOS No support NoSamsung Internet Android Full support Yes
hasChrome Full support 50Edge Full support 18Firefox Full support 39IE No support NoOpera Full support YesSafari Full support 11WebView Android Full support YesChrome Android Full support 50Edge Mobile No support NoFirefox Android Full support YesOpera Android Full support YesSafari iOS No support NoSamsung Internet Android Full support Yes
setChrome Full support 50Edge Full support 18Firefox Full support 39IE No support NoOpera No support NoSafari Full support 11WebView Android Full support YesChrome Android Full support 50Edge Mobile No support NoFirefox Android Full support YesOpera Android No support NoSafari iOS Full support YesSamsung Internet Android Full support Yes
entriesChrome Full support 50Edge Full support 18Firefox Full support 44IE No support NoOpera Full support YesSafari Full support 11WebView Android ? Chrome Android Full support 50Edge Mobile No support NoFirefox Android Full support 44Opera Android Full support YesSafari iOS ? Samsung Internet Android ?
keysChrome Full support 50Edge Full support 18Firefox Full support 44IE ? Opera Full support YesSafari Full support 11WebView Android ? Chrome Android Full support 50Edge Mobile No support NoFirefox Android Full support 44Opera Android ? Safari iOS ? Samsung Internet Android ?
valuesChrome Full support 50Edge Full support 18Firefox Full support 44IE ? Opera ? Safari Full support 11WebView Android ? Chrome Android Full support 50Edge Mobile No support NoFirefox Android Full support 44Opera Android ? Safari iOS ? Samsung Internet Android ?
Support of for...ofChrome Full support 50Edge No support NoFirefox Full support 44IE ? Opera ? Safari Full support 11WebView Android ? Chrome Android Full support 50Edge Mobile No support NoFirefox Android Full support 44Opera Android ? Safari iOS ? Samsung Internet Android ?
Available in workersChrome Full support YesEdge Full support YesFirefox Full support 39IE No support NoOpera Full support YesSafari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS No support NoSamsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

See also

문서 태그 및 공헌자

이 페이지의 공헌자: mdnwebdocs-bot, wisedog, DeadIntegral, SangMin_Kang, HanHyeoksu
최종 변경자: mdnwebdocs-bot,