Welcome Guest, Not a member yet? Register   Sign In
File upload
#1

[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>
&lt;form acti echo base_url('documents/save_document'); ?&gt;" id="new_document_form" class="forms" method="post" enctype="multipart/form-data"&gt;
&lt;input type="file" name="attached_file" id="attached_file" accept="application/pdf" multiple&gt;
&lt;/form&gt;

----
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()Wink;
return false;
});
</code>
input:file value not showing in alert
#2

[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?
#3

[eluser]ninjayan[/eluser]
Yes I am. I didn't put all the codes here. Smile




Theme © iAndrew 2016 - Forum software by © MyBB