Pre Exam Test Practice (SSC | Banking | IAS | GATE | State Level | CLAT | Railways | Insurance | Teaching Exams | NDA | Defence | IES |State Exam )

Organizational Research By

Surprising Reserch Topic

ajax file upload using codeigniter

ajax file upload using codeigniter  using -'php,jquery,ajax,codeigniter,file-upload'

I'm trying to upload an image using codeigniter and ajax. I already have the ajax method to insert the field values to the DB, what's the easiest and simplest way to upload my file.
Here's the JQuery custom function:

    jQuery.fn.ajaxSubmit =
        function() {
            $(this).submit(function(event) {
                var url = $(this).attr('action');                       
                var data = $(this).serialize();

                    url: url,
                    type: "POST",
                    data: data,
                    dataType: "html",
                    success: function(msg) {

                 return this;

I call it like this:

$(document).ready(function() {    

The function works fine, the data gets inserted in the database and I even have some directories that get created in the model before uploading the image, they are created but the image is not uploaded at all.

I know I need to use a hidden Iframe to do the job, but I dont quite know how to integrate that in my code.

asked Sep 15, 2015 by Phi2283
0 votes

Related Hot Questions

Government Jobs Opening

" rel="nofollow" target="_blank">"> " rel="nofollow" target="_blank">">

In CodeIgniter Controller :

Hope this helps you. Thanks!!

answered Sep 15, 2015 by NoeRosenber