Php + html5 uses the FormData object to submit a form and upload an image. Php + html5 use FormData object to submit a form and upload an image. This article mainly introduces php + html5 using FormData object to submit a form and upload an image, the example shows how to submit a form and upload an image using the FormData object in FormDa php + html5.
This article describes how to submit a form and upload an image using the FormData object in php + html5. The example shows how to use the FormData object, which is very useful. For more information, see
This example describes how to submit a form and upload an image using the FormData object in php + html5. Share it with you for your reference. The specific analysis is as follows:
FormData object. you can combine the name and value of all form elements in form into a queryString and submit it to the background. When Ajax is used for submission, using the FormData object can reduce the amount of work required to splice queryString.
Use FormData object
1. create a FormData empty object and use the append method to add key/value
The code is as follows:
Var formdata = new FormData ();
Formdata. append ('name', 'fdipzone ');
Formdata. append ('gender', 'male ');
2. get the form object and pass it as a parameter to the FormData object
The code is as follows:
The code is as follows:
Var form = document. getElementById ('form1 ');
Var formdata = new FormData (form );
Use FormData to submit a form and upload a file:
The code is as follows:
FormData Demo