I am trying to upload image to a location through ajax using codeigniter and how to receive in the controller.
I have search too much but don't know where is the problem!
Ajax code:
$('#btnform2').click(function(e){
e.preventDefault();
// valadation_form();
$("form#data").submit(function(event){
//disable the default form submission
event.preventDefault();
//grab all form data
var formData = new FormData($(this)[0]);
$.ajax({
url: '<?php echo base_url(); ?>"+"index.php/club/post_ajax',
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
success: function (returndata) {
alert(returndata);
}
});
return false;
alert("test");
});
});
My form
<form method="post" class="form-horizontal" id="form_members" role="form" name="uploader">
<label for="fullname" class="col-sm-2">Full Name</label>
<input type="text" class="form-control" name="fullname" id="firstname" placeholder="Full Name" >
<label for="lastname" class="col-sm-2">Computer Number</label>
<input type="text" class="form-control" name="computernumber" id="lastname" placeholder="Computer Number">
<label for="address" class="col-sm-2">E- mail Address</label>
<input type="email" class="form-control" name="email" id="address" placeholder="Email Address">
<label for="city" class="col-sm-2">Mobile Number</label>
<input type="text" class="form-control" list="cities" name="mobilenumber" id="mobilenumber" placeholder="Mobile Number">
<label for="phone" class="col-sm-2">Nationality</label>
<input type="tel" class="form-control" name="Nationality" id="nationality" placeholder="nationality">
<label for="email" class="col-sm-2">Upload Photo</label>
<input id="file" class="file" type="file" multiple data-min-file-count="1">
<button name="submit" class="btn btn-warning" id="btnform2">Update Player Profile</button>
</form>