Dear programmers and rescuers,
I am facing a problem with my sign-up page. I use jquery to send all the form information to my PHP file. Now I want to add the function that people can also upload their profile picture. But, when I add it, it won't work.
This is my current code:
<script>
$(function () {
$('button').bind('click', function (event) {
event.preventDefault();
$.ajax({
type: 'POST',
url: '../includes/register.inc.php',
data: $('form').serialize(),
success: function(data){
document.getElementById("notification").innerHTML = (data);
}
});
});
});
</script>
In my PHP file I handle it like;
$fname = $_POST['voornaam'];
$lname = $_POST['achternaam'];
$gebr = $_POST['gebruikersnaam'];
$email = $_POST['email'];
$gdatum = $_POST['gdatum'];
$pass = $_POST['wachtwoord'];
$pass2 = $_POST['herhaal-wachtwoord'];
$imgFile = $_FILES['user_image']['name'];
$tmp_dir = $_FILES['user_image']['tmp_name'];
$imgSize = $_FILES['user_image']['size'];
But my PHP code gives an error that index user_image
is not defined. How can I send the file upload to my PHP file with my jquery code?
Thanks for helping me.
Kind regards, Serge