I am new in CI and I am trying to upload image but dont know why its not uploading, Here is my view,
<form action="<?php echo site_url('admin/test/'.$param2.'/add'); ?>" enctype="multipart/form-data" method="post" id = 'mcq_form'>
    <input type="hidden" name="question_type" value="mcq">
    <div class="input-group">
        <div class="custom-file">
            <input type="file" class="custom-file-input" id="attachment" name="attachment" onchange="changeTitleOfImageUploader(this)">
            <label class="custom-file-label" for="attachment"><?php echo get_phrase('attachment'); ?></label>
        </div>
    </div>
    <div class="text-center">
        <button class = "btn btn-success" id = "submitButton" type="button" name="button" data-dismiss="modal"><?php echo get_phrase('submit'); ?></button>
    </div>
</form>
<script>
    $('#submitButton').click( function(event) {
        $.ajax({
            url: '<?php echo site_url('admin/test/'.$param2.'/add'); ?>',
            type: 'post',
            data: $('form#mcq_form').serialize(),
            success: function(response) {
               if (response == 1) {
                   success_notify('<?php echo get_phrase('question_has_been_added'); ?>');
               }else {
                   error_notify('<?php echo get_phrase('no_options_can_be_blank_and_there_has_to_be_atleast_one_answer'); ?>');
               }
             }
        });
        showLargeModal('<?php echo site_url('modal/popup/test/'.$param2); ?>', '<?php echo get_phrase('test'); ?>');
    });
</script>
on Controller I am trying to get image data but dont know why its not fetching,
print_r($_FILES['attachment']['name']);
die();
I don't understand, what I am missing. Please help me out.
