Home

Published

- 1 min read

jquery serialize with file upload

img of jquery serialize with file upload

The solution for this is noted below

jquery serialize with file upload

Solution

   ;<form>
	<p>
		Upload file: <input type='file' name='file' />
	</p>
	<input type='button' value='Upload' onclick='upload()' />
</form>
function upload() {
	var formData = new FormData($('#uploadForm')[0])
	$.ajax({
		url: '',
		type: 'POST',
		data: formData,
		async: false,
		cache: false,
		contentType: false,
		processData: false,
		success: function (data) {},
		error: function (data) {}
	})
}

Try other methods by searching on the site. That is if this doesn’t work