I have below code which is submit form using Jquery AJAX with image upload. When ajax call server file I cannot acces $_FILES variable.
function submitForm()
{
var data = $("#ff").serialize();
$.ajax({
type : 'POST',
url : 'register_process.php',
data : data,
contentType: false,
cache: false,
processData:false,
beforeSend: function()
{
$("#error").fadeOut();
$("#register_btn").html(' sending ...');
},
success : function(response)
{
if(response=="ok"){
//$("#register_form_succ").fadeIn();
$("#register_form_succ").html('Registration successful <a href="index.php">Click here</a> to login');
}
else{
$("#error").fadeIn(1000, function(){
$("#error").html(' '+response+' !');
});
}
}
});
return false;
}
and HTML below
<form method="POST" action="register.php" enctype="multipart/form-data" id="ff" name="reg">
<div>
<b> I am new user !</b><br/><br/>
</div>
<label>
<span>Full Name *:</span>
<input type="text" placeholder="Please enter Full Name" name="name" id="name" autofocus>
</label>
<label>
<span>Username *:</span>
<input type="text" placeholder="Please enter Username" name="username" id="username">
</label>
<label>
<span>Password *:</span>
<input type="password" placeholder="Please enter Password" name="password" id="password">
</label>
<label>
<span>Email *:</span>
<input type="email" placeholder="Please enter Email" name="email" id="email">
</label>
<label>
<span>Photo *:</span>
<input type="file" name="photo" id="photo">
</label>
<input type="submit" class="sendButton" name="register_btn" name="register_btn" value="Save"/>
<div>I already Registered.<a href="index.php"> Login here</a></div>
</form>
But in register_process.php i cant get $_FILES variable. it is blank