I am posting a form to itself with jquery which has a file upload in it. I cannot get the file name, i keep getting userfile is not set... when trying to capture the file name
$(document).ready(function(){
$("#chmail").validate({
debug: false,
submitHandler: function(form) {
$.post('new_mail.php', $("#chmail").serialize(), function(data) {
$('#mainBody').html(data);
$("#mainBody").find("script").each(function(i) {
eval($(this).text());
});
});
}
});
});
if (isset($_FILES["userfile"]["name"])) {
echo $_FILES["userfile"]["name"];
}
<form method="post" action="" id="chmail" name="chmail" enctype="multipart/form-data">
<input type="file" id="userfile" name="userfile" />
<button type="submit" value="Send">
</form>
Any help would be appreciated :) Many thanks