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

2 Answers

0 votes

Here is a good tutorial which should answer you questions. Just a little google action

Ajax upload with codeigniter

That is an extensive tutorial, but at least it is done the right way. Take the time to read it :)

answered Sep 15, 2015 by LeonoreKoers
0 votes

I created custom Ajax File Uploader using CodeIgniter, jQuery and Malsup form plugin. Here is the HTML and Javascript/CSS code. It also support multiple file upload and Progress.

        Ajax UP Bar
        " rel="nofollow" target="_blank">">
        " rel="nofollow" target="_blank">">




In CodeIgniter Controller :

Hope this helps you. Thanks!!

answered Sep 15, 2015 by NoeRosenber