File upload |
[eluser]ninjayan[/eluser]
I have a form which accepts user inputs and a file. I am not using the CI upload class and want to use the core php in uploading. My problem is when I check if the $_FILES is empty or not. I'm not sure why $_FILES is ignored in CI. Please have a look <code> <form acti echo base_url('documents/save_document'); ?>" id="new_document_form" class="forms" method="post" enctype="multipart/form-data"> <input type="file" name="attached_file" id="attached_file" accept="application/pdf" multiple> </form> ---- controller ---- if (!empty($_FILES['attached_file']['tmp_name'])) { $data['errors'] = 'a'; } else { $data['errors'] = 'b'; } </code> Here is my jquery form submit code <code> $('#new_document_form').on('submit', function(){ var save_form = $(this); alert(save_form.serialize(); return false; }); </code> input:file value not showing in alert
[eluser]rana[/eluser]
You don't need to use $_FILES variable to implement file upload functionality in codeigniter. Checkout this following demo with CI code: CodeIgniter File Upload Demo Example Not sure what your jquery is doing here. Are trying to submit via ajax mode?
|
Welcome Guest, Not a member yet? Register Sign In |