Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const formData = new FormData();
- formData.append("username", "Groucho");
- formData.append("accountnum", 123456);
- const fileInputElement = document.getElementById( 'myFile' );
- formData.append( fileInputElement.name, fileInputElement.files[0], fileInputElement.files[0].name );
- formData.append("userfile", fileInputElement.files[0]);
- formData.append("webmasterfile", new Blob(['<a><b>hey!</b></a>'], { type: "text/xml"}), "data.xml");
- const xhr = new XMLHttpRequest();
- xhr.open("POST", "http://foo.com/submitform.php");
- xhr.onload = function(){
- if ( xhr.status >= 200 && xhr.status < 400 )
- console.log( "Response: " + xhr.responseText );
- };
- xhr.onerror = function(){
- console.log( "Failed" );
- };
- xhr.send(formData);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement