Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8011309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:59:00+00:00 2026-06-04T18:59:00+00:00

I’m currently developping some forms for my school project with CodeIgniter. The idea is

  • 0

I’m currently developping some forms for my school project with CodeIgniter.

The idea is that I have a form with image upload. I’m trying to do it dynamically with Ajax but it seems not working at all. I tried the non-dynamic version with php and It works perfectly, my images are in my folder and I have no problem with it.

I tried like 5 or 6 plug-ins with no results, it is certainly my fault but I don’t know where I did a mistakes.

<—Controller—>

if($result = $this->images_model->add_bdd())
{   
    $data['uploaded'] = $result;
    $data['message_upload'] = 'Image uploader avec succès.';                            
    $this->template->set_title('Upload successful');
    $this->template->view('add_places',$data);
}
else
{   
    $this->template->set_title('Upload failed');
    $this->template->view('add_places');
}

<–Model–>

function add_bdd()
{
    $config = array(
                'allowed_types' => 'jpg|jpeg|tiff',
                'upload_path' => $this->gallery_path,
                'max_size' => 2000,
                'remove_spaces' => TRUE,
                'overwrite' => FALSE
            );

    $this->load->library('upload',$config);
    if ($this->upload->do_upload())
    {

        $data_img = $this->upload->data();
        $exif = $this->exif_extractor->coords($data_img['full_path']);
        $data = array(
                'titre' => 'titlecontent',
                'url' => base_url('images/'.$data_img['file_name']),
                'url_min' => base_url('images/'.$data_img['raw_name'].'_min'.$data_img['file_ext']),
                'alt' => 'cover_contentName',
                'id_users' => $this->session->userdata('id'),
                'date_upload' => date('Y-m-d H:m'),
                'date_modified' => date('Y-m-d H:m'),
                'lat' => $exif[0],
                'long' => $exif[1],
                );
        $this->db->insert('pictures',$data);
        return $exif;
    }
    else
    {
        return false;
    }
}

<–View–>

<form action="http://localhost:8888/project/images/add" method="post" accept-charset="utf-8" enctype="multipart/form-data">
<input type="file" name="userfile" value="Image de couverture"  />
<button name="upload" type="button" id="upload">Upload</button>
<input type="submit" name="submit" value="Publish Place"  />
</form>

Can anyone give me a jQuery plugin to upload images dynamically and send back to the script my images with the path and others data that I want to return ?

I can’t paste like all the code I made for jQuery, but I really need help about it. It’s been 2 days that I’m on it!

Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:59:00+00:00Added an answer on June 4, 2026 at 6:59 pm

    Thanks for you help, I change my dynamic about the script so now, it works perfectly with what I have to do.

    There is the script for my upload system :

    <– VIEW (upload_img)–>

    <div id="container">
    <div id="filelist"></div>
    <a href="http://localhost:8888/myproject/#" id="userfile" name="userfile">[Select files]      </a>    
    <a href="http://localhost:8888/myproject/images/index#" id="uploadfiles">[Upload files]</a
    </div>
    

    <– CONTROLLER –>

    function index(){
        if($this->_access())
        {
            $this->template->add_include('js/jquery.js')
                           ->add_include('js/browserplus.js')
                           ->add_include('js/plugins/plupload/plupload.full.js')
                           ->add_include('js/imgfunc.js');
            $this->template->view('upload_img');
        }
        else
        {
            redirect(site_url());
        }
    }
    
    function upload_image_spot()
    {
        if($query = $this->images_model->upload_image_spot())
        {
            echo json_encode($query);
        }
        else
        {
            echo $this->upload->display_errors('', '');
        }
    }
    

    <– MODEL –>

       function upload_image_spot()
    {
        $config['upload_path'] = realpath(APPPATH. '../images/spots');
        $config['allowed_types'] = 'jpg|jpeg|tiff|png';
        $config['max_size'] = 3062;
        $config['encrypt_name'] = TRUE;
        $this->load->library('upload', $config);
        if($this->upload->do_upload('file')) 
        // file means the file send to the website for upload, this is the name of field for Plupload script
        {
        $data_img = $this->upload->data();
        $copies = array(
                array('dir' => 'images/spots/large/', 'x' => 1000, 'y' => 600),
                array('dir' => 'images/spots/thumb/', 'x' => 100, 'y' => 60)
        );
    
        $this->copies($data_img,$copies);
    
        return 'whatever'; // Not real data, I don't wanna post them here
        }
    }
    

    <– JS-SCRIPTS –>

    First of all include :

    -jQuery

    -browserPlus

    -Plupload

    (Plupload Script)

    Now add this script in an empty file:

    var uploader = new plupload.Uploader({
        runtimes : 'gears,html5,flash,silverlight,browserplus',
        browse_button : 'userfile',
        container : 'container',
        max_file_size : '3mb',
        url : 'yourUploadFunctionCI',
        flash_swf_url : 'plugins/plupload/js/plupload.flash.swf',
        silverlight_xap_url : 'plugins/plupload/js/plupload.silverlight.xap',
        filters : [
            {title : "Image files", extensions : "jpg,jpeg,JPG,JPEG,tiff,png"},
        ]
    });
    
    uploader.bind('Init', function(up, params) {
    });
    
    $('#uploadfiles').click(function(e) {
        uploader.start();
        e.preventDefault();
    });
    
    uploader.init();
    
    uploader.bind('FilesAdded', function(up, files) {
        $.each(files, function(i, file) {
            $('#filelist').html("");
            $('#filelist').append(
                '<div id="' + file.id + '">' +
                file.name + ' (' + plupload.formatSize(file.size) + ') <b></b>' +
            '</div>');
        });
    
        up.refresh();
    });
    
    uploader.bind('UploadProgress', function(up, file) {
        $('#' + file.id + " b").html(file.percent + "%");
    });
    
    uploader.bind('Error', function(up, err, msg,file) {
        $('#filelist').append("<div>Error: " + err.code +
            ", Message: " + err.message +
            (err.file ? ", File: " + err.file.name : "") +
            "</div>"
        );
        console.log(msg,up,err);
        up.refresh();
    });
    
    uploader.bind('FileUploaded', function(up, file,response) {
        $('#' + file.id + " b").html("100%");
        var data = jQuery.parseJSON(msg.response);
        console.log(data);
    });
    

    Do your own customization and that’s it, no need extra script like you can see on website like copy/paste all script from a php file to a controller, just add ‘file’ inside do_upload and everything’s gonna work fine !

    Have a nice day guys, hope it’s help.

    Simon

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.