I am trying to submit form data with jQuery but it is showing some strange behavior. Let me explain what is mean by "strange". If I use the HTML code below:
<form id="upload" enctype="multipart/form-data">
<input type="text" name="myfile" id="myfile" />
</form>
and this jQuery code:
$("#myfile").bind("change",function() {
var data = $('form#upload').serialize();
alert(data);
});
It shows the expected result but if I change the HTML code to:
<form id="upload" enctype="multipart/form-data">
<input type="file" name="myfile" id="myfile" />
</form>
It simply does not show anything. I've also tried FormData()
instead of serialize()
but same result. I've also tried reading data on server-side but it also shows the same.
I'm Using PHP as server-side language.