I am attempting to upload images. I use almost the exact same code on another page and it works fine However, here when I try and upload an image and alert out the formData
to test, it’s empty. I have been tying to trouble shoot but nothing is working. Below is the php form and the jQuery script – and the empty alert box. Again these work fine on the other page. Any ideas what Im doing wrong here?
<form name="upload_media_form" id="upload_media_form" enctype="multipart/form-data" action="#" method="post">
<div class="page_box stacked_lo image_preview_tray">
<label for="upload_main_media" style="" class="upload_media_heading">ADD MEDIA</label>
</div>
<input type="file" id="upload_main_media" name="upload_main_media" hidden/>
<input type="hidden" name="upload_type" value="main_media" />
</form>
jQuery
$('#upload_media_form').on('submit',(function(e) {
e.preventDefault();
e.stopPropagation();
var formData = new FormData(this);
alert (JSON.stringify(formData));
return false;
}))